0

the below code getting parent configurable parent image even if simple, So how to get the simple url also?

$_item = $block->getItem();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$_product = $objectManager->get('Magento\Catalog\Model\Product')->load($_item->getProductId());
$productImageUrl = $block->getBaseUrl().'pub/media/catalog/product'.$_product->getImage();

Thanks

  • Hey Did you find solution? – 3CE Oct 30 '17 at 14:39
0

Try below code:

$_item = $block->getItem();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $objectManager->create('Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable')->getParentIdsByChild($_item->getProductId());
if(isset($product[0]))
{
   $parentProductId = $product[0];
   $_product = $objectManager->get('Magento\Catalog\Model\Product')->load($parentProductId);
   $productImageUrl = $block->getBaseUrl().'pub/media/catalog/product'.$_product->getImage();
}
  • Hi @Kishan Patadia Thank you for sharing with me this code, but unfortunately its not working. Do you have any idea to get current loaded product ID think if i found this way will working fine. – MagEGY May 13 '17 at 16:18
  • In which page you are trying to use it ? – Kishan Patadia May 13 '17 at 17:03
  • Its order view page – MagEGY May 13 '17 at 17:42
  • If frontend or backend ? – Kishan Patadia May 13 '17 at 18:30
  • Oh sorry, backend – MagEGY May 13 '17 at 19:10

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.