0

I try to use my customized .phtml file for a certain category.

I go in Admin->Catalog->Categories->Design->Layout update xml

I put the following code in the field layout update xml,

   <referenceContainer name="content">
        <referenceBlock name="product_list">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">Magento_Catalog::product/subcategory.phtml</argument>
            </action>
        </referenceBlock>
   </referenceContainer>  

and this is how my catalog_category_view.xml look like

   <referenceContainer name="content">
        <block class="Magento\Catalog\Block\Category\View" name="category.products"
               template="Magento_Catalog::category/products.phtml">
            <block class="Magento\Catalog\Block\Product\ListProduct" name="category.products.list" as="product_list"
                   template="Magento_Catalog::product/list.phtml">
            </block>
         </block>
   </container>

This is how the Design tab look like enter image description here

So I wanted is to use my customized template subcategory.phtml instead of list.phtml for a certain category.

But what I did has no effect on the site. I have cleared the cache.

1

I found it out. Apparently I need to use referenceBlock category.products,

The following code works for me.

<referenceContainer name="content">
    <referenceBlock name="category.products">
        <block name="product_list" class="Magento\Catalog\Block\Product\ListProduct">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">Magento_Catalog::product/subcategories.phtml</argument>
            </action>
        </block>
    </referenceBlock>
</referenceContainer>
0

Try using following code:

<referenceBlock name="product_list" template="Magento_Catalog::product/subcategory.phtml"/>

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.