I'm aware of how the XML system in Magento works with handles such as catalog_product_view.xml and catalog_category_view.xml to define resources for specific (sorts) of pages.

For seperate simple products I need to have different XML files. It should be possible via attribute sets and I found this list of obsolete handles, but I can't find any list of what would work.

I've tried to add products to an attribute set (ID 9) and creating catalog_product_view_attribute_set_id_9.xml which loads a JS file with a console.log for testing purposes; no result.

Does anyone have any insight on which layout handles I could use to make differences between the same product type?

1 Answer 1


Magento 2 introduces new layout handles.

First, there are the replacements for the M1 product types handles:

  • catalog_product_view_type_simple.xml
  • catalog_product_view_type_configurable.xml
  • catalog_product_view_type_grouped.xml
  • catalog_product_view_type_bundle.xml
  • catalog_product_view_type_virtual.xml
  • catalog_product_view_type_downloadable.xml

Then, there is the layout handle based on the product id:

  • catalog_product_view_id_%productid% where %productid% is the id of the product

And finally, there is a layout handle based on the product sku:

  • catalog_product_view_sku_%productsku% where %productsku% is the sku of the product

As of 2.1.2, there is no layout handle based on the attribute set.

  • So the best option to have one XML for a set of products is to create a custom product type and use that for the handle? Seems excessive.. As I understand correctly I COULD use the XML based on ID or SKU, but I'll have to make a XML per product? Also, can you explain why they'd make it based on productid AND productsku as they're both unique for each product?
    – Asitis
    Commented Nov 10, 2016 at 9:55
  • 1
    @AlexTimmer Question 1: yes I reckon so. Question 2: unfortunately yes 1 XML per product. Question 3: I guess the purpose is to be able to modify layout for single products. Commented Nov 10, 2016 at 10:07
  • Raphael: Thanks for quick and clear answers!
    – Asitis
    Commented Nov 10, 2016 at 10:21

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.