My magento shop has 3 main categories, each of them having 4 sub-categories

My 3 categories are 3 kinds of products : let's say Fruits, Cars, Clothes. They each have a general colour theme Fruits => Green, Cars => blue, Clothes=> red. this colour is used as page background. I do that by having 3 different layouts that extend the 1column default layout.

In my sub-category listing, I have used pictures in JPG (for lower file size), they then have a background that matches the colour theme of their category. The pictures do not fill the product cell in the category view and the rest of the cell has matching background colour.

Now, in search results page, I use similar layout as sub-category, I might have search results that yield products from all 3 main categories. I would like the background of the product cell to match the colour of the category it belongs to (and the colour of the JPG image background).

How can I fetch the "design" attribute of the category the products belongs to? (I will then apply CSS classes accordingly)

Magento 2.1.0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.