Advertisement
Guest User

Untitled

a guest
May 5th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. require_once '../app/Mage.php';
  2. Mage :: app("default") -> setCurrentStore( Mage_Core_Model_App :: ADMIN_STORE_ID );
  3. $skuAll =array();
  4. $file_handle = fopen("skus.csv", "r");
  5. while (!feof($file_handle) ) {
  6. $line_of_text = fgetcsv($file_handle, 1024);
  7. $allSku = $line_of_text[0];
  8.  
  9. }
  10. $products = Mage::getResourceModel('catalog/product_collection')
  11. ->addAttributeToSelect('*')
  12. ->addAttributeToFilter(
  13. 'sku', array('in' => $allSku)
  14. )
  15. ->load();
  16.  
  17. if(is_array($products))
  18. {
  19. foreach ($products as $key => $pId)
  20. {
  21. try
  22. {
  23. $product = Mage::getModel('catalog/product')->load($pId)->delete();
  24. echo "successfully deleted product with ID: ". $pId ."<br />";
  25. }
  26. catch (Exception $e)
  27. {
  28. echo "Could not delete product with ID: ". $pId ."<br />";
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement