cancel
Showing results for 
Search instead for 
Did you mean: 

How to call Block in product detailed page?

How to call Block in product detailed page?

i had created custom block in content -> block -> xyz (block name) now i wan to call this block in product detailed page.

How can i call this block in product detailed page?

3 REPLIES 3

Re: How to call Block in product detailed page?

Add Below code on catalog_product_view.xml

<referenceContainer name="content">
<block class="Magento\Cms\Block\Block" name="unick_block_name">
<arguments>
<argument name="block_id" xsi:type="string">my_cmsblock_identifier</argument>
</arguments>
</block>
</referenceContainer>

You need to replace "my_cmsblock_identifier" with your CMS block Identifier or ID (i recommend using Identifier).

If issue solved, Click Kudos & Accept as Solution.
LitCommerce - The Most Simple & Affordable Multi-channel Selling Tool

Re: How to call Block in product detailed page?

The Information you shared above is great. I have been reading all you shared here. In this you explained everything very well. If i want any further guideline we will contact you here https://community.magento.com/t5/forums/replypage/board-id/magento-2-bik-theming/message-id/4093.

Thanks

Re: How to call Block in product detailed page?

This depends upon  you where you want to call your cms block in product details page as there are different files for different location.
But you need to use this code to call your custom cms block in your phtml file:

<?= $this->getLayout()
          ->createBlock('Magento\Cms\Block\Block')
          ->setBlockId('your_block_identifier')
          ->toHtml();
?>