Which of the following code samples will link a configurable product’s images to its constituent simple products, in the product details page?

  • $_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]); }

  • $_childIdArray = Mage::getModel(‘catalog/product_type_configurable’)->getChildIds($_product->getId()); if(sizeof($_childIdArray)==1 && Mage::getModel(‘catalog/product’)->load($_childIdArray[0])->getTypeId() == ‘configurable’){ $_product = Mage::getModel(‘catalog/product’)->load($_childIdArray[0]); }

  • $_parentIdArray = Mage::getModel(‘catalog/product’)->getIdsByChild($_product->getId()); if(sizeof($_parentIdArray) >= 1 && Mage::getModel(‘catalog/product’)->load($_parentIdArray[0])->getTypeId() == ‘configurable’){ $_product = Mage::getModel(‘catalog/product’)->load($_parentIdArray[0]); }

  • $_childIdArray = Mage::getModel(‘catalog/product’)->getChildIdsByParent($_product->getId()); if(sizeof($_childIdArray)==1 && Mage::getModel(‘catalog/product’)->load($_childIdArray[0])->getTypeId() == ‘configurable’){ $_product = Mage::getModel(‘catalog/product’)->load($_childIdArray[0]); }

stackoverflow.com/a/5061075