Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vkathirvel/8399747 to your computer and use it in GitHub Desktop.
Save vkathirvel/8399747 to your computer and use it in GitHub Desktop.
<?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);
$productSkusArray = array("EG1","EG2");
// Loop through the product array
foreach ($productSkusArray as $productSku) {
// Load the Magento product model by sku and delete
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $productSku);
if($product) {
try {
$product->delete();
echo $productSku . " Deleted<br>";
} catch (Exception $e) {
echo $productSku . " Not Deleted<br>";
}
} else {
echo $productSku . " Not Available<br>";
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment