I'm trying to apply an XML Layout Update to a small selection of categories to have a custom product listing design. All other categories need to remain as-is so I cannot simply globally change the product list template for all categories.

I have already made various attempts to do this including (Where Namespace_Module is my own module with a list.phtml)

<referenceBlock name="category.products.list" template="Namespace_Module::list.phtml" />


<referenceBlock name="category.products.list">
        <argument name="template" xsi:type="string">%Namespace_Module::list.phtml%</argument>

Is there any restriction on overriding certain blocks? I can't see what is wrong with the above for this not to work?

To confirm, I'm applying this in the Category > Layout Update XML as that is the only place I can do it dynamically for a range of categories

I'm running Magento v2.1.3

  • Have u tried Layout Update XML? – Ankit Shah Mar 9 '17 at 9:14
  • Yes, I might not have made it clear in my question but this is the only place I have (and can) apply this (Category -> Layout Update XML) because I want to apply this to a selection of categories – Turv Mar 9 '17 at 9:21
  • @Turv this part works for Config: Category -> Layout Update XML ? – Khoa TruongDinh Mar 9 '17 at 13:52

I took a look the source code of Magento 2.1.3 version, it used <action method="setTemplate">:

<referenceBlock name="category.products.list">
     <action method="setTemplate">
        <argument name="template" xsi:type="string">%Namespace_Module::list.phtml%</argument>
  • This is exactly what I needed. Whilst I'm convinced I had attempted SetTemplate in the past this worked perfectly! – Turv Mar 9 '17 at 15:14
  • perfect. new to magento2. could you please tell where do the list.phtml file go? – Magento Learner Jun 12 '17 at 13:47
  • Do you have a custom module? The list.phtml should put under template folder. – Khoa TruongDinh Jun 12 '17 at 13:48

Your Answer

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

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