Skip to main content

Posts

Showing posts from March, 2017

Programatically Delete Products by Sku ( Using CSV )

Hi All, Recently while working on a project. I need to delete products from Magento and I only have a CSV having all the product's SKU. For that I have written a script which reads SKU from CSV file and deleting products. Below is the code which you can use: <?php //Path to Magento require_once('app/Mage.php'); umask(0); Mage::app(); ini_set('display_errors', 1); // Register a secure admin environment Mage::register('isSecureArea', 1); $file = "remove_product.csv"; // CSV File name with SKU's $fileData=fopen($file,'r'); if (($handle = fopen("remove_product.csv", "r")) !== FALSE) {   while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {     $num = count($data);     $row++;     for ($c=0; $c < $num; $c++) {         echo $data[$c] . "<br />\n";         $sku = $data[$c];         $product = Mage::getModel('catalog/product')->loadByAttribut