Magento 2.1.6 – Can’t Override list.phtml

cataloglist.phtmlmagento2theme-fallback

I'm trying to override Magento_Catalog list.phtml in magento 2.1.6 and it's not working. I have a theme working and others templates and layouts overrides are working correctly.

My custom list.phtml is here:

app\design\frontend\vendor\theme\Magento_Catalog\templates\product\list.phtml

If I remove "category.product.list" in my "catalog_category_view.xml" in

app\design\frontend\vendor\theme\Magento_Catalog\layout

with this funcion:

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

product grid disappears.

I've tried also to disable modules but it's not working.

I'm doing tests modifying list.phtml line 68 link class:

    <a class="product-item-link test"

And in my grid isn't showing this change.

Best Answer

Since when doing reference for removing it works , i m guessing that you are using the current active theme.

Make sure you are in developer mode and then I would try to clean pub/static and var/view_preprocessed and redeploy static content. If this doesn't work try and extend the layout. In app\design\frontend\vendor\theme\Magento_Catalog\layout\catalog_category_view.xml

......
<referenceContainer name="content">
        <block class="Magento\Catalog\Block\Category\View" name="category.products" template="Magento_Catalog::category/products.phtml">
            <block class="Vendor\Module\Block\Product\ListProduct" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml">
...... rest of file depending on what you are extending

I had to extend ListProduct.php for different reasons so i don't know if it works with default but this is working for me.

Related Topic