+1 vote
1.9k views
in Magento by
Would you be able to advise the easiest way to generate a report of all products that do not belong to any categories. Will likely want to check this when I am finished with the import and development just in case I has missed some.

1 Answer

+1 vote
by
<?php
require_once('app/Mage.php');
umask(0);
Mage::app('admin');
set_time_limit(0);

$i=0;
$sql = "select
    type_id,sku
 from catalog_product_entity a
 left join catalog_category_product cp on cp.`product_id` = a.entity_id
 left join catalog_product_relation cpr on cpr.child_id = a.entity_id
 where
       cp.product_id is null
   and cpr.parent_id is null
   and a.type_id = 'configurable'";
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
//echo count($connection->fetchAll($sql));exit;

foreach ($connection->fetchAll($sql) as $arr_row) {
        $pid = $arr_row['sku'];
        $product = Mage::getModel('catalog/product')->loadByAttribute('sku',$pid);
        if($product->getTypeId()!='configurable') continue;
        $i++;
        echo $i .") ". $product->getName() . " - " . $product->getSku() . "<br>";
}
?>

Related questions

0 votes
2 answers 1.9k views
0 votes
1 answer 1.5k views
0 votes
0 answers 1.3k views
+1 vote
1 answer 1.2k views
+1 vote
1 answer 1.8k views
0 votes
1 answer 1.8k views
...