In this topic we will show you How to Change Product Image in Minicart in Magento 2 through 2 steps:

  • Step 1: Create di.xml file
  • Step 2: Create Image.php file
Change Product Image in Minicart in Magento 2
Change Product Image in Minicart in Magento 2

Product image in minicart will getten to  show by function doGetItemData() in Magento\Checkout\CustomerData\DefaultItem class but this function is protected, so we cannot use plugin on it. Instead, it extends from Magento\Checkout\CustomerData\AbstractItem and use function getItemData()

  • So we can use plugin on this function

Step 1: Create di.xml file

  • Create di.xml file in app/code/[Name_Space]/[Your_Module]/etc/frontend

Step 2: Create Image.php file

  • Create Image.php file in app/code/[Name_Space]\[Your_Module]\Plugin\Minicart

The steps I mention above is the shortest process for you to Change Product Image in Minicart in Magento 2. With this guide, you can manage the Product Image in Minicart in Magento 2 easily. Every store has a Product Image in Minicart in Magento 2 with many attributes.

Thank you for reading this post and see you in other posts from Magestore!


Ready to foster your knowledge

with MAGENTO 2 BASIC GUIDE

Is your site still a mess and Magento extensions are not enough to save your site? Save your site with Magento Web Development Services now

magento services


How to Get Parent Product Ids in Magento 2
How to Add Eav Attribute for Product in Magento 2

Leave a Reply

Your email address will not be published. Required fields are marked *