0

I try to switch the list.phtml for 4 categorys. Each category should have his own list.phtml.

The problem:

I don't want to call it by the category id directly. I know I can easy do this directly in the list.phtml file for every category.

I want to call it in the backend from magento 2.

product->category under design.

I used:

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

and

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

but none of them works.

The theme still use the list.phtml instead of my "list_souvenirs.phtml"

The list.phtml is called in the catalog_category_view.xml like this:

<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">

Its not a problem with my default.xml because I can delete the "breadcrumbs" for example.

<referenceBlock name="breadcrumbs" remove="true" />
0

Update and solution:

There is a ticket for this problem on github with a solution for fixing it temporary: https://github.com/magento/magento2/issues/7510#issuecomment-317691277

Short solution:

Do not create the

<referenceBlock name="category.products.list">

in the catalog_category_view.xml.

Then you can call it in the backend with you're custom list.phtml like this:

<referenceContainer name="columns.top">
<referenceBlock name="category.products.list">
     <action method="setTemplate">
        <argument name="template" xsi:type="string">Magento_Catalog::product/list_yourname.phtml</argument>
     </action>
</referenceBlock>

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.