Can somebody suggest an intermediate way to delete all products in magento and reset their table's increment id to 1 without using multiple "truncate" queries found when Googling ?

Magento version ce-1.9.x

1 Answer 1


to delete all the products, Create a file DeleteProduct.php inside your magento root folder and write the below code in that file and then execute it with below URL http://www.yourdomain.com/DeleteProduct.php try the below code :

$productCollection = Mage::getModel('catalog/product')
foreach($productCollection as $_product)
    $productID = $_product->getId();

    try {
        Mage::getModel("catalog/product")->load($productID)->delete(); // this will delete product
    } catch (Exception $exception){
        die('Exception Thrown');
  • @Manashvi birla as I said, I also want to reset the product's table auto-increment id to 1 along with deleting products.
    – Vicky Dev
    Commented Oct 5, 2015 at 6:53
  • u'll have to manually set the auto-increment like this ALTER TABLE table_name AUTO_INCREMENT = 1; Commented Oct 5, 2015 at 7:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.