Question

I had to change the images from

images\catalog\product\placeholder

but the problem is that the old images are still displaying because of cache in

media\catalog\product\cache

I found in the backend in System -> Cache Management the option to flush the images cache and it works great, but I need to do this from a migration file in order to flush this cache for everyone who works on my project.

So I searched for the code of backend button and it looks like this <button onclick="setLocation('<?php echo $this->getCleanImagesUrl()?>')" type="button" .... And in my migration file I tryed to do this

$block = Mage::app()->getLayout()->createBlock('adminhtml/cache_additional');
$block->getCleanImagesUrl();

But with no result. Can someone give me an idea on how to flush the cache from a migration file?

Was it helpful?

Solution

This should clean the images cache:

Mage::getModel('catalog/product_image')->clearCache();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top