0

I'm using Magento 2.3.5 and I have a requirement where I need to disable caching of product prices (both in catalog view and product view pages).

I read the product prices from an external service and they change based on several conditions. What I'm looking for is to achieve this without breaking the full_page cache.

Thanks in advance !

1 Answer 1

0

I think your best bet is to fetch the product prices asynchronously using ajax.

Depending on how many products you have you have some different options. If you do not have more than lets say 500-1000 products, you could probably fetch them once per session and keep them in local storage. If it is more you will probably need to fetch them every time they are needed.

For the backend it will be no problem, you just have to overide getPrice in the ProductInterface and use the price you have from your price service.

Then you can keep the full page cache on.

3
  • any tips on how I can load prices using ajax ?
    – Joao71
    Oct 21, 2020 at 8:57
  • How many products do you have? How often do your prices change? Are they based on customers being logged in ?
    – Kristoffer
    Oct 21, 2020 at 9:20
  • Hello. The prices are based on customer External ID. They cahnge outside of Magento in our ERP (I read them via webservice) and can change at any given time. I have around 3000 products on my website divided into three different stores.
    – Joao71
    Oct 21, 2020 at 9:56

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.