I want to delete all products which do not have a manufacturer with ID 1 or 2 or 3. This will be about 250000 products, so I have to use direct SQL. I wrote this code to get the SQL query. So I have the SKUs and could run a delete on those in
catalog_product_entity. Is there a better way? Maybe not going over sku, but directly using the manufacturer IDs?
$idsToKeep = array(1, 2, 3); $_productCollection=Mage::getModel('catalog/product')->getCollection() ->addAttributeToFilter('manufacturer', array('nin' => $idsToKeep))->load(); var_dump((string)$_productCollection->getSelect());