1

How can override theme .phtml file override into custom module.

Path theme .phtml file is app\design\frontend\ThemeName_CompanyName\Module_Catalog\templates\product\view\pricedifference.phtml and this file reference in app\design\frontend\ThemeName_CompanyName\Magento_Theme\layout\catalog_product_view.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-right" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
 <referenceContainer name="content">
            <container name="product.top.wrap" htmlClass="row" htmlTag="div">
                <container name="product.top">
                    <container name="product.info.left" htmlClass="col-sm-5" htmlTag="div">

                        <block class="Vendor\Module\Block\Template" name="product.info.pricedifference" template="Magento_Catalog::product/view/pricedifference.phtml" />
                    </container>
                    <container name="product.info.middle" htmlClass="col-sm-7" after="product.info.left" htmlTag="div" />
                </container>
            </container>
            <container name="product.bottom" />
        </referenceContainer>
</page>

How can override pricedifference.phtm into my custom module in app\code\vendor_module or add new block after exact this block?

1 Answer 1

1

To add a new block after product.info.pricedifference block.

In catalog_product_view.xml in your module add

<referenceContainer name="product.info.left">
    <block class="Vendor\Module\Block\FileName" 
           name="product.info.custom" 
           after="product.info.pricedifference"
           template="Vendor_Module::custom.phtml">
    </block>
</referenceContainer>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.