<?php
require_once '../app/Mage.php';
Mage :: app("default") -> setCurrentStore( Mage_Core_Model_App :: ADMIN_STORE_ID );
$skuAll =array();
$file_handle = fopen("skus.csv", "r");
while (!feof($file_handle) ) {
$line_of_text = fgetcsv($file_handle, 1024);
$allSku = $line_of_text[0];
}
$products = Mage::getResourceModel('catalog/product_collection')
->addAttributeToSelect('*')
->addAttributeToFilter(
'sku', array('in' => $allSku)
)
->load();
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 />";
}
}
}
?>
require_once '../app/Mage.php';
Mage :: app("default") -> setCurrentStore( Mage_Core_Model_App :: ADMIN_STORE_ID );
$skuAll =array();
$file_handle = fopen("skus.csv", "r");
while (!feof($file_handle) ) {
$line_of_text = fgetcsv($file_handle, 1024);
$allSku = $line_of_text[0];
}
$products = Mage::getResourceModel('catalog/product_collection')
->addAttributeToSelect('*')
->addAttributeToFilter(
'sku', array('in' => $allSku)
)
->load();
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 />";
}
}
}
?>
No comments:
Post a Comment