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.

  • Please check it in private browser or clear Local Storage from the browser and then check it, – Dhaduk Mitesh Jan 8 at 12:58
  • please attach code how to pass description and how to display description in html file – Rk Rathod Jan 8 at 13:18
  • Have you do what I say? – Dhaduk Mitesh Jan 8 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. – Dinesh Rajput Jan 8 at 13:43
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

| improve this answer | |
  • i think your did not get my problem, i have already done same way but not reflecting. – Shiv Singh Jan 8 at 13:16
  • what code you write for sort description value call ? @ShivSingh – Ansar Husain Jan 9 at 5:00
  • That is correct and i can see on Ajax response. screenshot: prnt.sc/ql7kv9 – Shiv Singh Jan 9 at 9:17
  • and what code you write in html file ?@ShivSingh – Ansar Husain Jan 9 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 Jan 9 at 9:27
0

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

Thanks.

| improve this answer | |

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.