4

I need to clear cache on certain condition from PHP code. How can I do so. I know that there is object Cache exists in opencart engine, but how do delete cache correctly.
Or it is possible to delete just folders ?
Please give advice.

4 Answers4

8

In OpenCart there are 3 places that store cache

  1. image cache is located at public_html/image/cache

  2. if you have vQmod public_html/vqmod/vqcache

  3. system (data) cache public_html/system/cache

You can delete files within these folders - do not delete the cache folders - only the content inside.

I hope this helps.

shadyyx
  • 15,825
  • 6
  • 60
  • 95
Brian
  • 127
  • 11
4

What you need to do is to take a look at some models in admin folder and check some add/delete methods, i.e. in admin/model/catalog/product.php the addProduct() method calls:

$this->cache->delete('product');

where 'product' is the key defining which cache to delete. Other keys might be category, language, currency, etc.

shadyyx
  • 15,825
  • 6
  • 60
  • 95
  • Your solution fails. For ex.: you replace primary product image, but preserve its name. Clearing cache with `$this->cache->delete('product')` doesn't affect on image cache - image still would be served with old img. – userlond Nov 28 '15 at 03:28
  • @userlond OP wasn't asking about image cache which is in your browser BTW. In all modern browsers, hitting CTRL + SHIFT + DELETE will open a window/page, where you can delete your browser cache - but this has nothing to do with OpenCart (i.e. your comment is completely OT). – shadyyx Nov 30 '15 at 10:54
  • Just for clarifying. I changed image of product with my own code, but preserved name of image (calling $this->cache->delete('product') was made). OC 2.0 still served old image from `image/cache` folder. I.e. clearing `image/cache` helped me... So it's nice addon to your answer. – userlond Dec 01 '15 at 00:15
  • Noty about browser caching is also useful in some situations – userlond Dec 01 '15 at 00:26
0

It works to me- Go to: Step 1. In admin dashboard click in Dashboard and you will get gearing icon in top right side and click on it. You get see Developer Settings. And you get find Cache and Action. So, in Cache click on Off and Click Refresh Icon in Action. Step 2. Admin > Extensions > Modifications > click on the Refresh Icon that you will see in top right side and check again.

Y. Joy Ch. Singha
  • 3,056
  • 24
  • 26
0

You can also do it manually or by clearing cache folder files by php script.

If you are using other than 3.X version then the cache folder is in : System > storage > cache

If its a 3.X version then got to storage folder wherever you have moved that then inside that folder there is a cache folder.

Clear cache folder data & reload your store page. This solution worked for me. Thanks for asking this question.

Kamlesh
  • 5,233
  • 39
  • 50