0

I'm having difficulty figuring out how to add a description to a Simple Product that will subsequently be displayed on the Simple Product Details Page. Everywhere I have looked discusses using code to handle this but like i said in my last post im new to magento and cannot figure out how to solve this issue with code solutions provided as they seem to gear towards more advanced developers.

  • Have you added description on product in admin panel? – Shoaib Munir Feb 4 at 4:35
  • @ShoaibMunir No that's what im looking for – jkushner Feb 4 at 15:59
1

To add product description in simple product only, you can follow below steps.

1) Create a catalog_product_view_type_simple.xml file in app/design/frontend/Vendor/Theme/Magento_Catalog/layout/catalog_product_view_type_simple.xml and paste below code in this file.

<?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="product.info.main">
            <block class="Magento\Catalog\Block\Product\View" name="product.description.simple" template="Magento_Catalog::product/view/type/simple/description.phtml" after="product.info.price"/>
        </referenceContainer>
    </body>
</page>

2) Create a description.phtml file in app/design/frontend/Vendor/Theme/Magento_Catalog/templates/product/view/type/simple/description.phtml and paste below code.

<?php
$_helper = $this->helper('Magento\Catalog\Helper\Output');
$_product = $block->getProduct();
$_attributeLabel = $_product->getResource()->getAttribute('description')->getStoreLabel();
$_attributeValue = ($_helper->productAttribute($_product, $_product->getDescription(), 'description')) ? $_product->getAttributeText('description') : '';
?>
<?php if ($_attributeValue): ?>
    <div class="product-description">
        <strong class="type"><?= /* @escapeNotVerified */ $_attributeLabel ?></strong>
        <div class="value"><?= /* @escapeNotVerified */ $_attributeValue ?></div>
    </div>
<?php endif; ?>

3) Flush magento cache and check simple product in which you have added description in backend.

  • Where do i add the product descriptions? – jkushner Feb 4 at 17:22
  • You can add product description here: Admin > Catalog > Products > Add New or Edit Product > Content > Description. In default magento, it is not required to code separately to show description. By default it will be display if you have added in backend. – Satish Dubariya Feb 5 at 4:15
  • Welcome and enjoy :) – Satish Dubariya Feb 6 at 4:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.