1
votes

I have an grouped product in Magento. Before I display the items associated with the group, I want to make sure each associated product is saleable. I'm testing by switching the 'Enabled/Disabled' status in the simple product's admin.

$sku = 'SKU1234'; // grouped product
$cpm = Mage::getModel('catalog/product');

$grouped_product = $cpm->load($cpm->getIdBySku($sku));
$associated = $cpm->getTypeInstance(true)->getAssociatedProducts($grouped_product);

foreach ($associated as $a_p) echo $a_p->isSaleable();

Regardless of the Disabled/Enabled status of an associated product, the above is always printing out a '1' for each associated product, whereas I would expect a '2' for 'Disabled.'

What am I missing?

Thanks for any help

1

1 Answers

0
votes

Sometimes the echo command doesn't work fine on output page.

Try to enable logging system in backend and the use the log command:

Mage::log($a_p->isSaleable());

Also try to log the $associated array to get more informations about the return class. Maybe you cannot use

$a_p->isSaleable();

and you have to use

$a_p->getProduct()->isSaleable();