Magento 2: Product types and layout handles

Published on 10 Nov 2016 , edited on 22 Mar 2019

I find this something worth documenting, for the sheer scope of sources, obsolete code and articles and different semi-functional workarounds I’ve found about it. The issue? loading separate XML layout files for products in Magento 2. In my particular case all the products are Simple Products and yet I need to have different XML layouts for some of them.

So these are my options:
– Creating a new, custom, product type, extending the Simple Product
– Create custom XML handles based on either an attribute, attribute set or best; category
– Use existing XML handles

And none of them have given me a clear answer yet, so I’ll start documenting here for the sake of progress.

Creating a new product type

Creating new XML handle (this is set in the Magento2 repo, but I think it’s about 1)


Everything web development related, rants, snippets, tutorials, quests; it’s all there.

All categories

All tags

All posts