I have overridden


file in my custom plugin using di.xml using below code:

<preference for="Magento\Checkout\CustomerData\Cart"
                 type="Vendor\Package\CustomerData\Cart" />

It's working too. I can get SectionData defined in my custom Cart.php file in Minicart successfully.

but this removes Total from my Minicart which was working fine with default Cart.php.

Please suggest if i am doing something wrong in overriding file.

Reference image

1 Answer 1


I solved this issue by following method:

File: di.xml

 <type name="Magento\Checkout\CustomerData\Cart">
      <plugin name="CustomMiniCart" type="Vendor\Package\CustomerData\Cart" sortOrder="1"/>


namespace Vendor\Package\CustomerData;
class Cart
    public function afterGetSectionData(\Magento\Checkout\CustomerData\Cart $subject, $result)

        $result['customdata1'] = $customvalue1;
        $result['customdata2'] =  $customvalue2;
        return $result;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.