Step:1
open this file app/design/frontend/default/default/template/catalog/product/view.php
and Add this code
if($_product->getTypeId() == "configurable"):
echo "<b>Associated Product Image :</b><hr><br>";
/**
* Load product by product id
*/
$product = Mage::getModel('catalog/product')->load($this->getProduct()->getId());
/**
* Get child products id (only ids)
*/
$childIds = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($product->getId());
/**
* Get children products (all associated children products data)
*/
$childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null,$product);
foreach($childProducts as $childProduct)
{
?>
<img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."catalog/product".$childProduct->getThumbnail() ?>" alt="<?php echo $childProduct->getName() ?>" title="<?php echo $childProduct->getName() ?>" width="50px" height="50px" />
<?php
}
endif;
?>
Delete Cache and refresh browser :)
open this file app/design/frontend/default/default/template/catalog/product/view.php
and Add this code
if($_product->getTypeId() == "configurable"):
echo "<b>Associated Product Image :</b><hr><br>";
/**
* Load product by product id
*/
$product = Mage::getModel('catalog/product')->load($this->getProduct()->getId());
/**
* Get child products id (only ids)
*/
$childIds = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($product->getId());
/**
* Get children products (all associated children products data)
*/
$childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null,$product);
foreach($childProducts as $childProduct)
{
?>
<img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."catalog/product".$childProduct->getThumbnail() ?>" alt="<?php echo $childProduct->getName() ?>" title="<?php echo $childProduct->getName() ?>" width="50px" height="50px" />
<?php
}
endif;
?>
Delete Cache and refresh browser :)
Great blog. All posts have something to learn. Your work is very good and i appreciate you and hoping for some more informative posts.keep writing
ReplyDeletemagento development company in bangalore