3

I want to use the different file for a category but not working.

For that I have change under Catalog > Categories > Layout Update XML

I have check with both arguments and action but not working

Path of my list File : Magento_Catalog::product/my-own-list.phtml

Using Action

<referenceBlock name="category.products.list">
     <action method="setTemplate">
        <argument name="template" xsi:type="string">Magento_Catalog::product/my-own-list.phtml</argument>
     </action>
</referenceBlock>

Using Argument

<referenceBlock name="category.products.list">
<arguments>
<argument name="template" xsi:type="string">Magento_Catalog::product/my-own-list.phtml</argument>
</arguments>
</referenceBlock>

1 Answer 1

10

Try with this:

<referenceContainer name="content">
    <referenceBlock name="category.products.list">
        <action method="setTemplate">
            <argument name="template" xsi:type="string">Magento_Catalog::product/my-own-list.phtml</argument>
        </action>
    </referenceBlock>
</referenceContainer>

Magento 2 for some reason doesn't allow <referenceBlock> as the starting element, but you can bypass this limitation by referencing the parent container.

2
  • I have clear the cache and working fine, thanks Jan 6, 2018 at 6:18
  • After adding <referenceContainer> I was still having trouble getting the updates to display in one environment. Turns out this category data is stored in an index and my cron:run was failing. Found this when running CLI magento indexer:reindex and layout updated started working.
    – Ian at SSU
    Apr 18, 2018 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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