- We can delete all the products in magento through script.
- Below is the code for to delete all the products in magento.
- Below is the code for to delete all the products in magento.
<?phpfunction deleteAllProducts(){ require_once '../app/Mage.php'; Mage :: app("default") -> setCurrentStore( Mage_Core_Model_App :: ADMIN_STORE_ID ); $products = Mage :: getResourceModel('catalog/product_collection')->setStoreId(1)->getAllIds(); if(is_array($products)) { foreach ($products as $key => $pId) { try { $product = Mage::getModel('catalog/product')->load($pId)->delete(); echo "successfully deleted product with ID: ". $pId ."<br />"; }
catch (Exception $e)
{ echo "Could not delete product with ID: ". $pId ."<br />"; } } }}deleteAllProducts();?>
No comments:
Post a Comment