Adding a preview product section on the product page
-
07-01-2021 - |
Question
I am fairly new to the Magento platform so excuse my lack of knowledge!
I'm working on a Magento 2 project.
I need to add a preview section for my products.
Ideally, it would be between the product-info-main and the product-info-detailed. I'm looking to place this:
My Flipbook Preview (iCatalogue Module)
I understand I would need to create a template file for this and add the block to the product page. I am reading/studying layouts, blocks and templates (devdocs - customizing layouts). To help speed up my learning, could someone point me in the right direction or let me know the best practice for customizing a layout page?
Solution
To display the block over the tabs on a product page from your module you need to create MODULE_ROOT/view/frontend/layout/catalog_product_view.xml
file with the following content:
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="Magento\Framework\View\Element\Template" name="your.block.name" template="Your_Module::preview.phtml" after="product.info.media" before="product.info.details"/>
</referenceContainer>
</body>
Consider specifying appropriate block class and template references in the code snippet.