Wednesday, 21 February 2018

How can I add a custom block to the products page in Magento 2?

In app/code/Namespace/Modulename/Magento_Catalog/layout/catalog_product_view.xml add like below code.
 You can use your required referenceContainer

 <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="alert.urls">
            <block class="Magento\Catalog\Block\Product\View" name="textblock" as="textblock" before="-" template="product/view/stockavilable.phtml" />
        </referenceContainer>
    </body>
</page>

No comments:

Post a Comment