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> -->
Evgeny Levinsky
  • 1,187
  • 1
  • 7
  • 12
Wahaj Moin
  • 81
  • 8
  • Please post your code – Vivek Kumar Jul 05 '18 at 14:45
  • ok wait a minute – Wahaj Moin Jul 05 '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 05 '18 at 15:38
  • default.html
    <!-- 
    
    <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 05 '18 at 15:39
  • Please update this in question itself – Vivek Kumar Jul 05 '18 at 16:01
  • done it in my question please check it out – Wahaj Moin Jul 05 '18 at 16:06

0 Answers0