How to add block near a product image in a product detail page in Magento 2
2 Answers
Add below code in \view\frontend\layout\catalog_product_view.xml and clean cache
<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<referenceContainer name="product.info.media">
<container name="" htmlTag="div" htmlClass="" before="skip_gallery_after.target">
<block class="" name="" template="" />
</container>
</referenceContainer>
</page>
Add below code and change block identifier name
app\design\frontend\YourVendor\YourTheme\Magento_Catalog\layout\catalog_product_view.xml
<referenceContainer name="content">
<block class="Magento\Cms\Block\Block" name="block-identifier" before="product.info.media">
<arguments>
<argument name="block_id" xsi:type="string">block-identifier</argument>
</arguments>
</block>
</referenceContainer>
Clear cache and check..
-
-
-
-
If you have created custom module, you can use my code as i mention in above answered. just have to use module layout xml file. Commented May 14, 2019 at 5:47