1

I'm trying to override the List.phtml and its block using preference I tried this

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="category.products.list" template="Vendor_module::product/list.phtml">
        </referenceBlock>
    </body>
</page>

but its not working for me and the di is

<preference type="PME\Hideprice\Block\Product\ListProduct"
                    for="Magento\CatalogSearch\Block\SearchResult\ListProduct"/>

how can I override this Thanks in advance

0

You can try below example

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="category.products.list">
            <arguments>
                <argument name="template" xsi:type="string"> Vendor_module::product/list.phtml </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>
  • and what about the block(ListProduct.php) to override?? – Asad Khan Feb 21 '19 at 7:35
  • <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <preference for="Magento\Catalog\Block\Product\ListProduct" type="TestApp\Blog\Block\Rewrite\Product\ListProduct" /> </config> Add inside etc/frontend/di.xml, create TestApp\Blog\Block\Rewrite\Product\ListProduct class and method that you want to override – Manish Bhojwani Feb 21 '19 at 17:42

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.