Reputation: 2970
i have the following code
$id = 19654;
$prod = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
$prod->addAttributeToFilter('entity_id',array('in'=> array($id)));
$prod->load();
using the following code
foreach($prod as $_prod)
{
var_dump($_prod->getData());
}
i can view almost all the data accosted with the configurable product i'm looking at, what i'm missing is at minimum, a list of entity_id's for the simple products that are associated with it
in terms of the database, i know the link between simple and configurable product is in either catalog_product_relation, catalog_product_super_link and/or catalog_product_link, ofcause, since i'm using a collection i can't just use an INNER JOIN
i'm running this code off from a test.php page in the root directory of my magento install
Upvotes: 1
Views: 170
Reputation: 17656
Try
$_product = Mage::getModel('catalog/product')->load($productId);
if($_product->getTypeId() == "configurable"){
$AssociatedProduct = $_product->getTypeInstance()->getUsedProducts();
}
Or
if($_product->getTypeId() == "configurable"){
$conf = Mage::getModel('catalog/product_type_configurable')->setProduct($_product);
$col = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
foreach($col as $simple_product){
var_dump($simple_product->getId());
}
}
See http://www.magentocommerce.com/boards/viewthread/41874/
Upvotes: 3