Magento 2.2.2 – Fix Layout Update XML for Category Not Working

magento2

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>

Best Answer

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.

Related Topic