Sep 19, 2011

Magento: Get parent product for configurable product.


$_product = Mage::getModel('catalog/product')->load(YOUR_SIMPLE_PRODUCT_ID);
$parentIdArray = $_product->loadParentProductIds()->getData('parent_product_ids');
print_r($parentIdArray);

Get associated configurable product



/**
* Load product by product id
*/
$product = Mage::getModel('catalog/product')->(YOUR_PRODUCT_ID);

/**
* 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);

Reference:
magento-how-to-get-all-associated-children-product-of-a-configurable-product
magento-get-parent-id-of-simple-product-associated-to-configurable-product

No comments: