1

I want to manipulate the products showing in my mini cart. I have configurable products, now i want to show only 1 parent configuration with color White if the customer has added Color white with size attribute M / L / XL.

example

So actually the code that im searching for would be where the array is created with the items to show.

0

As per your current requirement you might need to override below class by creating a plugin and doGetItemData is the function which should be of your interest.

Magento\Checkout\CustomerData\DefaultItem

| improve this answer | |
  • Hi thanks for your reply. This is only for each single item. I want to chagne the array where they are all in. Is this possible with this function? – Johan SB Sep 25 '18 at 7:00
0

I found the solution:

In di.xml

<type name="Magento\Checkout\CustomerData\Cart">
    <plugin name="checkout.cart.message" type="{Vendor}\{Module}\Plugin\CustomerData\CartPlugin" sortOrder="1"/>
</type>

In {Module}\Plugin\CustomerData\CartPlugin.php

public function afterGetSectionData()
{
    $totals         = $this->getQuote()->getTotals();
    $subtotalAmount = $totals['subtotal']->getValue();

    return [
        'summary_count'             => $this->getSummaryCount(),
        'subtotalAmount'            => $subtotalAmount,
        'subtotal'                  => isset($totals['subtotal'])
            ? $this->checkoutHelper->formatPrice($subtotalAmount)
            : 0,
        'possible_onepage_checkout' => $this->isPossibleOnepageCheckout(),
        'items'                     => $this->getRecentItems(),
        'extra_actions'             => $this->layout->createBlock(\Magento\Catalog\Block\ShortcutButtons::class)
                                                    ->toHtml(),
        'isGuestCheckoutAllowed'    => $this->isGuestCheckoutAllowed(),
        'website_id'                => $this->getQuote()
                                            ->getStore()
                                            ->getWebsiteId(),
    ];
}

In this function items is getting called in $this->getRecentItems(). Now i can manipulate protected function getRecentItems() in my plugin class.

| 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.