Custom Block to Product Page with selection attribute is not showing

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:

  1. 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
  2. Created a CMS Block with just the “<div class="samsung"><img src="{{media url="wysiwyg/image.png"}}" alt="" /></div>” with identifier “samsung-garanci
  3. 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; ?>
  1. 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


Go to Source of this post
Author Of this post: JadoBulku
Title Of post: Custom Block to Product Page with selection attribute is not showing
Author Link: {authorlink}