If you are looking to delete the products in Magento then you must do it programmatically with script as per the catalog. Before starting the whole code acquire the right store id as you might have multiple store’s in Magento respectively. You can choose to delete single or Bulk products depending on the requirement.
With below code you can load the product by id and delete it Programmatically .
<?php Mage::register("isSecureArea", 1); $productid = 10; //use your own product id try{ Mage::getModel("catalog/product")->load($productid)->delete(); } catch(Exception $e) { echo "Delete failed"; } ?>
To delete all products in Magento programmatically with script we are going to use Magento Mage calls. This method uses Mage class and removes every product in the Magento catalog respectively. This method is faster than manually deleting the products from admin. Re-confirm the store id once again and start the process for deleting all products in Magento with following steps.
Step 1:- Create a new file with name deleteproducts.php at root of the all files.
Step 2:- Paste the following precise code into deleteproducts.php
Step 3:- Run file using the url : http://yourexampledomain.com/deleteproducts.php
set_time_limit(0); // Set Time limit ini_set('memory_limit','512M'); // Memory Limit require_once './app/Mage.php'; Mage :: app("default")->setCurrentStore( Mage_Core_Model_App :: ADMIN_STORE_ID ); //$storeId = 1; $products = Mage :: getResourceModel('catalog/product_collection') ->setStoreId(1)->getAllIds(); if(is_array($products)) { foreach ($products as $key => $productId) { try { $product = Mage::getModel('catalog/product') ->load($productId)->delete(); echo "Successfully deleted Product With ID: ". $productId."<br>"; } catch (Exception $e) { echo "Could not delete Product With ID: ". $productId."<br>"; } } }
When it comes to children, there’s one universal truth: the right toy can spark imagination, build skills, and make memories…
In today’s digital age, where screens and gadgets dominate our children’s lives, there’s something heartwarming about a well-loved plush toy…
In a world dominated by screens and fast-paced routines, it’s easy to forget the simple magic of a toy in…
In the heart of Delhi’s vibrant streets lies a world where imagination meets innovation — the magical universe of toys.…
When was the last time a toy truly amazed you—not just as a product, but as a thoughtful tool for…
In the digital age, the way we experience childhood has changed, but the essence remains the same—imagination, exploration, and joy.…