Calling Developers!
We are reenergizing our code contribution process! Learn More

What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hello, does somebody ever handled “multiple attributes” for one abstract/concrete in Spryker success

Options
UPWG9AYH2
UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet

Hello,
does somebody ever handled “multiple attributes” for one abstract/concrete in Spryker successfully?

We currently need to represent a scenario where a product variant can have for example multiple colors like green, black and white but are not limited to just one of those colors. The user should get displayed a “multi-value” filter where he can select any of those colors. as long as he matches any color being in the variant, the product should be visible.

First idea was to set up multiple color attributes like color_1, color_2, color_3 etc. … but since we don’t know how many colors a product might have, we cannot declare it in advance. Also it makes no sense if the order of color changes … because if color_1 = red and color_2=white, it should be the same as color_1 = white and color_2 = red.

Technically it feels like it should behave more like a tag which can be filtered in elasticsearch also, but spryker seems not to be capable to handle this.

Any ideas/suggestions and or experience from your projects? Is there anything planned in future?

Best regards

Comments

  • U02DBNVTTAS
    U02DBNVTTAS Posts: 16 🧑🏻‍🚀 - Cadet
    Options

    Usually color is super attribute and every color equals separate concrete product.

    Product abstract = T-shirt
    Product concrete 1 = Black T-shirt
    Product concrete 2 = Blue T-shirt

    etc.

  • U02DBNVTTAS
    U02DBNVTTAS Posts: 16 🧑🏻‍🚀 - Cadet
    Options

    The filters you described will work as well in such case.

  • UK7KBE2JW
    UK7KBE2JW Posts: 463 🧑🏻‍🚀 - Cadet
    Options

    We use it and spryker can do it out of the box. The only error is the BE, but its is fixable with twig and if you want to also save it in zed there is a lil more effort to do. The attribute value has to be saved as an array in database, synced with ES and redis and voila, everything works fine as multi value filter in FE.

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet
    Options

    @U02DBNVTTAS I am not sure if you got me right. Its not about having one color as a super attribute … its more about that ONE concrete has multiple Colors attached .. so instead of being a blue variant, its blue AND red AND yellow at the same time … but whenever i choose one of those 3 colors, the variant should be in the result set

  • UK7KBE2JW
    UK7KBE2JW Posts: 463 🧑🏻‍🚀 - Cadet
    Options

    you mean something like this?

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet
    Options

    yes but for one variant … the multi filter is originally intended to use across variants i guess …

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet
    edited October 2022
    Options

    so must be something like color = {brown, yellow, red …} …

  • U02DBNVTTAS
    U02DBNVTTAS Posts: 16 🧑🏻‍🚀 - Cadet
    Options

    @UPWG9AYH2 ah.. I used color_1, color_2… as you mentioned in the original message. (primary, secondary, thirdary) So not good way was found by me

  • UK7KBE2JW
    UK7KBE2JW Posts: 463 🧑🏻‍🚀 - Cadet
    Options

    this is one variant. in my example its a shoe. another variant has for example blue, red

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet
    Options

    yeah thats the problem if you dont know how many colors will be used in the end … thats why i think it must more behave like a tag or a label

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet
    Options

    but how does ES work with this? How to split in separate filters again on yves again? seems to me complicated

  • UK7KBE2JW
    UK7KBE2JW Posts: 463 🧑🏻‍🚀 - Cadet
    Options

    the split is made automatically

  • UK7KBE2JW
    UK7KBE2JW Posts: 463 🧑🏻‍🚀 - Cadet
    Options

    each color will be one facete

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet
    Options

    really? okay then in backend the form has to be extended to accept something like a json you mentioned?

  • UK7KBE2JW
    UK7KBE2JW Posts: 463 🧑🏻‍🚀 - Cadet
    Options

    no json, just array. try it yourself. edit the attributes in db and trigger the event for sync to es and redis.

  • UK7KBE2JW
    UK7KBE2JW Posts: 463 🧑🏻‍🚀 - Cadet
    Options

    zed will throw exception for viewing the attributes, but you can check via twig if productAttributes[localeCode][key] is iterable and handle it different. So you can implement something like tagging or something else. Or you handle it as json but for saving you have to convert it back to array. many ways for archiving this goal

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet
    Options

    thanks, ill try that … do you know if this is documented somewhere? I am really not aware of this capability but it’s maybe very essential to us

  • UK7KBE2JW
    UK7KBE2JW Posts: 463 🧑🏻‍🚀 - Cadet
    Options

    Nope, sry. Last week I had the to do for a technical spike for this stuff. So I only analyzed and debugged this and made the internal docs and a protoype for some ways of solving this. Next week we will discuss which way we take

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet
    Options

    Thanks a lot guys, i’ll try something 🙂

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet
    Options

    Okay, it does not seem to work ootb. I managed it to have it as an array synced to redis with the attribute map like


    ```

    "super:attr:test": [

    "Option 1",
    [
    "Option 1",
    "Option 3"
    ],
    "Option 2"
    ],

    ```

    But if i define it as a filter its just showing Option 1 and 2, but not Option 3 … what am i missing? 🤔

  • UK7KBE2JW
    UK7KBE2JW Posts: 463 🧑🏻‍🚀 - Cadet
    Options

    dunno if it can handle handle those

  • UK7KBE2JW
    UK7KBE2JW Posts: 463 🧑🏻‍🚀 - Cadet
    Options

    maybe you have to extend this case

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet
    Options

    yes, i have to look … so i think there are two cases … this one is about product variations … the other is about filtering on the category pages … if the latter would work ootb, it would help me a lot

  • UK7KBE2JW
    UK7KBE2JW Posts: 463 🧑🏻‍🚀 - Cadet
    Options

    I think im my case, we only use it for normal attributes, not for super attributes which are nested like you do

  • UPWG9AYH2
    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet
    Options

    But even for “normal” attributes … so I am a bit confused now. How does it behave ootb on your side? How do you use it?
    I can see the attributes coming as an array from Redis for the product abstract attribute map, but won’t return as a filterable value from elasticsearch … i expected now something that when i add a filter to the category page for such an attribute that can be selected then … but it does not seem to behave like this

  • UK7KBE2JW
    UK7KBE2JW Posts: 463 🧑🏻‍🚀 - Cadet
    Options

    For me it will show up in ES as attribute array and also for every value a string facet

  • UK7KBE2JW
    UK7KBE2JW Posts: 463 🧑🏻‍🚀 - Cadet
    Options

    In FE it shows up as single filter