Home » Magento3 August 2015

Magento: Add a custom block inside another block

You can add custom blocks inside already existing block through your custom layout xml file. You don’t need to change the template (phtml) code.

Suppose, you want to add a block inside product view page. To do so, you can write the following xml code in your custom module’s layout file. In the below code, I have added a button in product view page.

Note: output=”toHtml” is required to print the button.

Another example: Below code will add the custom button after Add to Cart button in product view page.

Hope this helps. Thanks.


Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed

Comments are closed.