I want to add custom code in my catalog category view page. I don't want to override product/list.phml file .

But, Just display my custom code in catagory view page after product price.

How to add it?

enter image description here


2 Answers 2


I find one way. Maybe It'll helpful for you.

Create di.xml file at /app/code/Vendor/Module/etc/frontend/di.xml :

<type name="Magento\Catalog\Block\Product\ListProduct">
    <plugin name="block-product-list" type="Vender\Module\Plugin\ProductList"/>

Create Plugin file ProductList.php at /app/code/Vendor/Module/Plugin :

namespace Vender\Module\Plugin;

class ProductList

    public function aroundGetProductDetailsHtml(
        \Magento\Catalog\Block\Product\ListProduct $subject,
        \Closure $proceed,
        \Magento\Catalog\Model\Product $product
    ) {
        echo "call";

Add the below code in calatog_category_view.xml and replace the block name and template name with your custom block and template name

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <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">
                    <block class="Magento\Catalog\Block\Product\ProductList\Item\Container" name="category.product.addto" as="addto">

                        <block as="product_list_blockname"  
                            template="<template path>"/>


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.