Magento – Magento 2. How to override List.phtml

frontendlist.phtmlmagento2

I want to Override List.phtml and for that I'm using this Layout

Vender/Module/view/frontend/layout/catalog_category_view.xml

    <?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> 
        <referenceContainer name="content"> 
             <block class="Magento\Catalog\Block\Product\ListProduct" name="category.products.list" as="product_list" template="Vender_Module::product/list.phtml"/>
        </referenceContainer>
    </body>
</page>

I also create the custom list.phtml and ListProduct.php in my Module but after that still my module is not running my list.phtml its running its own list.phtml. What is the problem and how can I solve that Thanks in advance.

Best Answer

Currently, the code is adding a new block in the content area not overriding any phtml file.

Replace the code with the following code.

<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">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">Vender_Module::product/list.phtml</argument>
            </action>
        </referenceBlock>
    </body>
</page>

Reference