I am trying to create an option where I can select yes or no in the backend, and when it’s set to yes, it adds a block with an image in the product page. Here’s what I have so far:
- I created a Yes/No Attribute called “samsung_5_vjet_garanci” and
made sure its Visible on Catalog Pages on Storefront. Added it on a sample product, and set it to YES - Created a CMS Block with just the “<img src=”{{media url=”wysiwyg/image.png”}}” alt=”” />” with identifier “samsung-garanci”
- Created a .phtml file and uploaded it /app/design/frontend/vendor/themename/Magento_Catalog/templates/product/view/samsung.phtml
<?php $_product = Mage::getSingleton('catalog/product')
->load($_product->getId());
if ($_product->getAttributeText('samsung_5_vjet_garanci') == "Yes"): ?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('samsung-garanci')->toHtml(); ?>
<?php endif; ?>
-
Added a block in catalog_product_view.xml
<referenceContainer name="product.info.main"> <block class="MagentoCatalogBlockProductView" name="samsung" as="samsung" after="-" template="Magento_Catalog::product/view/samsung.phtml" /> </referenceContainer>
But it’s not working, what am I doing wrong, it’s been 3 days figuring this out, and still nothing.
Thank you very much if you help me