I'm trying to get a list of all grouped products with no associated products.
I have the following code but it is not showing anything.
I know there is a least one grouped product with no associated products because I created a test one.
require_once '*<path-to>*/app/Mage.php';
Mage::app();
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToFilter('type_id', array('eq' => 'grouped'));
foreach ($products as $product) {
$associatedProducts = $product->getTypeInstance(true)->getAssociatedProducts($product);
$NoAssociatedProducts = count($associatedProducts);
if ($NoAssociatedProducts <1){
$grouped_name = $product->getName();
echo $grouped_name;
}
}
Can anyone see what's wrong?