If you want to show the bundle product image when the child product added in the cart programmatically, please follow the below step.
Step 1). Create file app/code/Magemonkeys/Cart/etc/di.xml
1 2 3 4 5 6 |
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Checkout\CustomerData\AbstractItem"> <plugin name="Change_Product_Image_In_Minicart" type="Magemonkeys\Cart\Plugin\Minicart\Image" sortOrder="1"/> </type> </config> |
Step 2). Create file app/code/Magemonkeys/Cart/Plugin/Minicart/Image.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
<?php namespace Magemonkeys\Cart\Plugin\Minicart; class Image { public function aroundGetItemData($subject, $proceed, $item) { $result = $proceed($item); $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $product = $objectManager->create('Magento\Catalog\Model\Product')->load($result['product_id']); $parentId = $objectManager->create('Magento\GroupedProduct\Model\Product\Type\Grouped')->getParentIdsByChild($result['product_id']); /* thumb url */ $storeManager = $objectManager->create('Magento\Store\Model\StoreManagerInterface'); $currentStore = $storeManager->getStore(); $mediaUrl = $currentStore->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA); if (isset($parentId[0])) { $id = $parentId[0]; $productdata = $objectManager->create('\Magento\Catalog\Model\Product')->load($id); $result['product_image']['src'] = $mediaUrl."catalog/product".$productdata->getThumbnail(); }else{ $result['product_image']['src']; } return $result; } } |
[crayon-63e09ae3314c1955784780/] Using above fucntion Images can be imported directly from...
Override view block using di.xml and add the below code...
You can check a list of called layout XML for...
Follow the below steps to install and set up PWA...
If you want to remove all leading zero's from order,...
Let our Magento expert connect to discuss your requirement.
We offer Magento
certified developers.
Our Magento clientele
is 500+.
We sign NDA for the
security of your projects.
We’ve performed 100+
Magento migration projects.
Free quotation
on your project.
Three months warranty on
code developed by us.