I have a lot of categories with different levels (parent/child structure) and I want to implement different design/structure of each level category.
Suppose I have these categories
=> Category A (first Level)
=>=> Category B (Second level)
=>=>=> Category C (third level)
=>=>=>=> Category D (fourth level)
I have two solutions
-
Create a xml file
catalog_category_view_id_{{id}}.xml
Issue: I can't implement because I have many categories and it will be difficult to update in futures
-
Change the category page layout of each category
Issue: It’s not working because I think, I have already updated catalog_catalog_view.xml in my theme or its Magento bug
Please guide me about some better solution
Best Answer
One option would be adding a layout handle based on the category depth with an observer on the
layout_load_before
event. That would allow layout updates based on category depth using an xml file likecatalog_category_view_level_{{level}}.xml
I tested this real quick by adding the following layout file removing breadcrumbs from level 2 categories: