I want to customize return value of $block->getProductDetailsHtml($_product)
(in list.phtml
) using plugin method, not overrite list.phtml
Magento2 Plugin – How to Overwrite Function Using Plugin Method
magento2plugin
magento2plugin
I want to customize return value of $block->getProductDetailsHtml($_product)
(in list.phtml
) using plugin method, not overrite list.phtml
Best Answer
Block
Magento\Catalog\Block\Product\ListProduct
extendsMagento\Catalog\Block\Product\AbstractProduct
.AbstractProduct
havegetProductDetailsHtml($_product)
so you need to add plugin forAbstractProduct
Vendor/Module/etc/frontend/di.xml
Vendor/Module/Plugin/Block/Product/AbstractProduct.php
Note: We can use
after
,before
,around
so you need to decide which is the best suite for you. Refer this link for how to use.I have checked, it works