Coding

Magento: remove all product imagesimages

 <?php

require_once '../app/Mage.php';
Mage::app();
Mage::app()->getStore()->setId(Mage_Core_Model_App::ADMIN_STORE_ID);
 
$products = Mage::getModel('catalog/product')->getCollection();
 
$mediaApi = Mage::getModel("catalog/product_attribute_media_api");
 
foreach($products as $product) {
$prodID = $product->getId();
$_product = Mage::getModel('catalog/product')->load($prodID);
$items = $mediaApi->items($_product->getId());
if (count($items) > 0) { 
foreach($items as $item) {
$mediaApi->remove($_product->getId(), $item['file']);
}
echo $product->getId() . " done \n";
} else { 
echo $product->getId() . " has no images \n";
}
}
?>

0 Bình luận

Trở về
  • HTML5 Canvas
  • HTML5 Canvas

     The <canvas> element is used to draw graphics, on the fly, on a web page. Draw a red rectangle, a gradient rectangle,...