0

I am trying to get the image of child (associated product) of a configurable product on wishlist page. Currently, parent image is shown which is not desired.

What I already have done:

In this file, I have been trying to get it:

 /template/wishlist/item/column/image.phtml

//my code
if ($product->getHasOptions()) { // mean it is configurable product
$my_options = new Mage_Wishlist_Block_Customer_Wishlist_Item_Options();
$my_config_options = $my_options->getConfiguredOptions();
if ($my_config_options) {
//try to find some link to the image
}

But it is not helping out. My above code may not be good enough, but I am just trying to reflect that I did try it myself.

2 Answers 2

1

This what I used to get simple product image to show in wishlist instead of configurable product image. You need to get the simple/child product ID of associated product and then get its attributes, in this case image.

$item_s = Mage::getModel('wishlist/item')
     ->loadWithOptions($item->getId(), 'simple_product')
     ->getOptionsByCode();
$simple_product = $item_s['simple_product']->getData();
// Simple product id
$simple_product_id = $simple_product_data['product_id'];
// Load associated product attribute by id
$simple_product_attr = Mage::getModel('catalog/product')->load($simple_product_id);
// Get Image
$simple_product_img_url = $this->helper('catalog/image')->init($simple_product_attr ,'small_image');

echo $simple_product_img_url into the html img src attribute.

0

I know this is a bit late, but for anyone looking for the answer:

$item = $this->getItem();
$simpleProduct = $item->getOptionsByCode()['simple_product']->getItem()->getProduct();

This is in the wishlist/item/column/image.phtml file

That code gives you the simple product that goes with the selection. Then it's a simple matter of getting the image from there.

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.