This is the situation:
I have a configurable product with several simple products. These simple products need to have the same product image as the configurable product. Currently I have to upload the same image to each simple product over and over again.
Is there a way to link the product image of the configurable product to the simple products?
Some of my products have 30 simple products in 1 configurable product and it is overkill/annoying to upload the same image 30 times.
I hope someone can help me with this problem!
Thanks in advance!
Insert this into your DOCROOT\app\design\frontend\<pachage>\<theme>\template\catalog\product\view\media.phtml
after $_product = $this->getProduct();
$_parentIdArray = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($_product->getId());
if(sizeof($_parentIdArray)==1 && Mage::getModel('catalog/product')->load($_parentIdArray[0])->getTypeId() == 'configurable'){
$_product = Mage::getModel('catalog/product')->load($_parentIdArray[0]);
}
That will use the images belonging to the parent configurable product if the simple product has a single parent of type configurable.
EDIT
To use this in the list view, open DOCROOT\app\design\frontend\<pachage>\<theme>\template\catalog\product\list.phtml
and insert the same code block in 2 locations:
<?php foreach ($_productCollection as $_product): ?>
(inside the <?php ?>
wrappers)<?php $i=0; foreach ($_productCollection as $_product): ?>
Both locations are required to deal with the grid view and list view versions of the page.
HTH,
JD
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With