Created
August 31, 2013 09:01
-
-
Save cfaria/6397057 to your computer and use it in GitHub Desktop.
Remove all product images MagentoFrom http://blog.gilesbennett.com/batch-remove-images-from-products-in-magento/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); | |
//->addAttributeToFilter('entity_id', array('gt' => 14000)); | |
$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()); | |
foreach($items as $item) { | |
$mediaApi->remove($_product->getId(), $item['file']); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment