0

I followed this link for minicart customization but i did not work for me href "I want to customize my minicart in Magento 2. I need to add 3 attributes "

I followed above link but my minicart not working as before follow above link... i just want to add sku and product id into the minicart.

<?php
namespace Matech\Minicart\Plugin; //use Magento\Quote\Model\Quote\Item;

class DefaultItem
{
    public function aroundGetItemData($subject, \Closure $proceed, Item $item)
    {
        $data = $proceed($item);
        $product = $item->getProduct();

        $atts = [
            'product_id' => $product->getAttributeText('product_id'),
            'product_sku' => $product->getAttributeText('sku')
        ];

        return array_merge($data, $atts);
    }
}


default.html
<!-- wahaj -->
<div data-bind="html: 'SKU#: ' + item.product_sku"></div>
<div data-bind="html: 'id: ' + item.product_id"></div>

<!-- wahaj -->
<!-- <div data-bind="html: 'SKU#: ' + item.product_sku"></div>
<div data-bind="html: 'Manufacturer: ' + item.product_manufacturer"></div>
<div data-bind="html: 'Part #: ' + item.product_part_number"></div> -->
  • Please post your code – Vivek Kumar Jul 5 '18 at 14:45
  • ok wait a minute – Wahaj Moin Jul 5 '18 at 14:50
  • <?php namespace Matech\Minicart\Plugin; //use Magento\Quote\Model\Quote\Item; class DefaultItem { public function aroundGetItemData($subject, \Closure $proceed, Item $item) { $data = $proceed($item); $product = $item->getProduct(); $atts = [ "product_id" => $product->getAttributeText('product_id'), "product_sku" => $product->getAttributeText('sku') ]; return array_merge($data, $atts); } } – Wahaj Moin Jul 5 '18 at 15:38
  • default.html <!-- wahaj --> <div data-bind="html: 'SKU#: ' + item.product_sku"></div> <div data-bind="html: 'id: ' + item.product_id"></div> <!-- wahaj --> <!-- <div data-bind="html: 'SKU#: ' + item.product_sku"></div> <div data-bind="html: 'Manufacturer: ' + item.product_manufacturer"></div> <div data-bind="html: 'Part #: ' + item.product_part_number"></div> --> – Wahaj Moin Jul 5 '18 at 15:39
  • Please update this in question itself – Vivek Kumar Jul 5 '18 at 16:01

Your Answer

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

Browse other questions tagged or ask your own question.