0

my client want to show short description under mini cart title:

You can see image screenshot:

enter image description here

I used grep command found it coming from :/vendor/magento/module-checkout/CustomerData/DefaultItem.php

and using html template file from: /Magento_Checkout/web/template/minicart/item/default.html

so i have passed short description from DefaultItem.php to Ajax response show short description and Same changes on html template file default.html also but not reflecting on front.

i have cleared caches, deployed content and tried on private browser but still not working.

4
  • Please check it in private browser or clear Local Storage from the browser and then check it, Commented Jan 8, 2020 at 12:58
  • please attach code how to pass description and how to display description in html file Commented Jan 8, 2020 at 13:18
  • Have you do what I say? Commented Jan 8, 2020 at 13:27
  • Please load the site in browser & check in network tab with pub file path "default.html" and open it. Has it the code for short desc ? If no, add directly inside it and save. check if it is work. you also don't need to run command as you are working in pub file path directly. Commented Jan 8, 2020 at 13:43

2 Answers 2

1

You need to override this file

/vendor/magento/module-checkout/CustomerData/DefaultItem.php

and add call sort description value here like below

/**
     * {@inheritdoc}
     */
    protected function doGetItemData()
    {
        $imageHelper = $this->imageHelper->init($this->getProductForThumbnail(), 'mini_cart_product_thumbnail');
        $productName = $this->escaper->escapeHtml($this->item->getProduct()->getName());

        return [
            'options' => $this->getOptionList(),
            'qty' => $this->item->getQty() * 1,
            'item_id' => $this->item->getId(),
            'configure_url' => $this->getConfigureUrl(),
            'is_visible_in_site_visibility' => $this->item->getProduct()->isVisibleInSiteVisibility(),
            'product_id' => $this->item->getProduct()->getId(),
            'product_name' => $productName,
            'product_sku' => $this->item->getProduct()->getSku(),
            'sort_description'=>'sort_description',
            'product_url' => $this->getProductUrl(),
            'product_has_url' => $this->hasProductUrl(),
            'product_price' => $this->checkoutHelper->formatPrice($this->item->getCalculationPrice()),
            'product_price_value' => $this->item->getCalculationPrice(),
            'product_image' => [
                'src' => $imageHelper->getUrl(),
                'alt' => $imageHelper->getLabel(),
                'width' => $imageHelper->getWidth(),
                'height' => $imageHelper->getHeight(),
            ],
            'canApplyMsrp' => $this->msrpHelper->isShowBeforeOrderConfirm($this->item->getProduct())
                && $this->msrpHelper->isMinimalPriceLessMsrp($this->item->getProduct()),
        ];
    }

And override this file in your theme

/Magento_Checkout/web/template/minicart/item/default.html

and add below code in file

<div class="sort-description" data-bind="html:sort_description"></div>

You will sure get description in minicart

6
  • i think your did not get my problem, i have already done same way but not reflecting.
    – Shiv Singh
    Commented Jan 8, 2020 at 13:16
  • what code you write for sort description value call ? @ShivSingh Commented Jan 9, 2020 at 5:00
  • That is correct and i can see on Ajax response. screenshot: prnt.sc/ql7kv9
    – Shiv Singh
    Commented Jan 9, 2020 at 9:17
  • and what code you write in html file ?@ShivSingh Commented Jan 9, 2020 at 9:19
  • 1
    Fixed now by: setup:static-content:deploy -f and by the way its not help to me but i will accept it as correct answer so it will help to others :)
    – Shiv Singh
    Commented Jan 9, 2020 at 9:27
0

How can I get the value of short description instead a text line "sort-description"?

Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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