2

I want to customize the design of the catalog list page. I want to use different layout and design for each product category. For that, I am calling different phtml files from static block. using a static block I am calling another phtml file but still in product list page default Magento list.phtml files are load. I don't know what actually issue please help me!

I am using Magento 2.1.1 version

1
  • Did you get solution? Commented Sep 19, 2020 at 13:46

3 Answers 3

7

You need to create a xml file catalog_category_view_id_{{id}}.xml under your theme > Magento_Catalog > layout and change list file.

For detail : http://sumankc.com/2016/12/10/different-template-for-different-categories-in-magento-2-category_id-layout-handle-in-m2/

2
  • hi Bhudiya, Could you please how you achieved ? I want to create different templates for different category top menu
    – Sushivam
    Commented Feb 21, 2017 at 6:37
  • Can we create xml file by category url key? Commented Sep 19, 2020 at 13:18
5

Created customlist.phtml from list.phtml or copied the code of list.phtml and create

Assign customlist.phtml in admin side (admin → category → Layout section)

<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/customlist.phtml</argument>
            </action>
        </block>
    </referenceBlock>
</referenceContainer>
1

I'm unable to add a comment so I'm going to post an answer.

catalog_catalog_view.xml has a block with the product list template in there. If you didn't remove it from that xml file, then it will always display in all the other product category.

Is the list.phtml suppose to only load on certain pages?

If so, then in admin > products > categories > you product category, under design, you can add the below code to update the layout and have the list.phtml removed from that category page.

<block name="category.products.list" remove="true"/>

Let me know if this is what you were looking to do.

Your Answer

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

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