I need to remove all product images (small, thumbnail and base) from directory. What would be a better way to do this?

  • 1
    Are you talking about unassigning product images from products? – Vivek Kumar Dec 13 '17 at 13:14
  • Yes! I also want to delete the images from folders (media/catalog/product). All of them. – Andressa Rodrigues Dec 13 '17 at 13:19

You can use below code to remove image from product and also from image path

$product = Mage::getModel('catalog/product')->loadByAttribute('sku','acj005');
$MediaCatalogDir=$MediaDir .DS . 'catalog' . DS . 'product';


foreach($MediaGallery as $eachImge){
    $MediaCatalogDir=$MediaDir .DS . 'catalog' . DS . 'product';
    // remove file from Dir

    $io     = new Varien_Io_File();


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.