0

I'm new to Magento 2 and trying to figure out the way to implement the following scenario:

We have categories with custom attribute which is multi-select. These attributes need to be category-specific.

Eg: Category : Supplier 1, Custom attribute : Supplier Type --> Values: Local, Offline etc.

Now we need to add this filter in the layered navigation filter - side tab on the product listing page with filter values like Local, Offline, etc.

Is there is way to show this category-custom attributes in sidebar filters like product attributes?

Or

To Create some custom attributes in the product page with the value of the same option as of category custom attribute and update values when category-custom attribute is updated using some queue job. Is this the right way to do it in Magento2

  • how we can trigger jobs when category custom attributes are updated?

Any suggestions?

1
  • Unrelated but make sure to know that : For multiselect, the required type is varchar instead of type text otherwise it won't work with filter. And about your question, I don't think thats possible, it might be possible to make a job when the category is updated only i guess. And in that job then you might want to check what is modified to make your modification there.
    – Claims
    Commented Nov 8, 2021 at 10:50

2 Answers 2

0

Create a multi select product attribute with same as category attribute ,,Set the values for that attribute, and update all products with that custom values. then after --

  1. Just go to product attributes on backend.
  2. choose your custom attribute
  3. Click on Storefront Properties , select Use in Layered Navigation field as Filterable (With result) 4.Save Attribute , Clear cache ,Then test it.
2
  • It is not feasible to update millions of products' custom attributes separately and also custom attributes are category-specific. Is there any way to update the product attribute while updating the category attibute?
    – stefun
    Commented Nov 8, 2021 at 11:30
  • No , but if you create a category attribute only for product sku,,Write a code in layered navigation ,that when your multiselect value choose then get these product sku or id . I think it will help you .
    – smruti
    Commented Nov 8, 2021 at 11:50
0
  1. Create a product attribute

  2. Create a Cron that should run and set the product attributes checking there category attribute values.

  3. Use these product attributes to display layered navigation collection.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.