Please try below code,
$products = Mage::getResourceModel('catalog/product_collection')->getAllIds();
foreach ($products as $key => $productId)
{
try {
$product = Mage::getSingleton('catalog/product')->load($productId);
Mage::dispatchEvent('catalog_controller_product_delete', array('product' => $product));
$product->delete();
} catch (Exception $e) {
echo "<br />Cannot delete product ID: $productId";
}
}
$products = Mage::getResourceModel('catalog/product_collection')->getAllIds();
foreach ($products as $key => $productId)
{
try {
$product = Mage::getSingleton('catalog/product')->load($productId);
Mage::dispatchEvent('catalog_controller_product_delete', array('product' => $product));
$product->delete();
} catch (Exception $e) {
echo "<br />Cannot delete product ID: $productId";
}
}
No comments:
Post a Comment