2

On a custom template I try to do the following calls:

    $a = $this->getProduct()->getData('short_description');
    $b = $this->getProduct()->getData()['short_description'];
    $c = $this->getProduct()->getAttributeText('short_description');
    $d = $this->getProduct()getShortDescription();

All of them return null, $this->getProduct() being a instance of Magento\Catalog\Model\Product. It works with other arguments though.

On the database, this argument has properties is_visible and is_visibile_on_front set to 1.

Additionally I tried setting the following block on the layout without using a custom template.

 <block after="-" class="Magento\Catalog\Block\Product\View\Description" name="product.info.short_description" template="Magento_Catalog::product/view/attribute.phtml">
    <arguments>
        <argument name="at_call" xsi:type="string">getShortDescription</argument>
        <argument name="at_code" xsi:type="string">short_description</argument>
    </arguments>
</block>

Also tried to do a var_dump($this->getProduct()->getData())). Short description was in place along other attributes and properties.

How to get the short description?

0

Let's try with below method:

$_helper = $this->helper('Magento\Catalog\Helper\Output');
<?= /* @escapeNotVerified */ $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>

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.