Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 />";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement