1

I am moving cart items to wishlist when store is switched using below code:

etc/frontnend/events.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="controller_action_predispatch">
        <observer name="mymodule_move_cart_to_wishlist" instance="Vendor\General\Observer\MoveCartToWishlist" />
    </event>
</config>

Vendor/General/Observer/MoveCartToWishlist.php

<?php
namespace Vendor\General\Observer;
// use statements

class MoveCartToWishlist implements ObserverInterface
{
    public function __construct(
        // dependencies
    )
    {
        // variable assignment
    }

    public function execute(Observer $observer)
    {
        // logic to move cart items to wishlist
    }
}

As per my logic cart items are moved to wishlist successfully.

Now, how I can refresh minicart section from my observer ?

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.