This is a follow up of

Magento2 : How to show New label in product list page

If I understand the proposed solution correctly, the product will still be shown as new as long as the full page cache does not expire.

What is an elegant solution for this?

I have something like the following in mind:

  • Detect somehow if product is no longer new (for example a cron that runs once a day, detect if the current day is just product-is-new-until plus one) or cache the latest state of product-is-new

  • If the product is now longer new, clear the product related cache tag.

Would that work? Did anybody do something like this, yet?

  • Normally if you are using FPC you need to clear FPC once in a day , then need to run Crawling script for early access. using sitemap.xml file Commented Jan 22, 2019 at 13:46
  • I would not like to clear the FPC ---> would appreciate if it can stay for a longer time.
    – Alex
    Commented Jan 22, 2019 at 13:49

1 Answer 1


step 1: create a cronjob which needs to run once in a day

step 2: get collection of products expired yesterday (something like this "NewsToDate" == date("Y-m-d", strtotime("-1 day")) )

step 3 : iterate collection and invalidate product cache

$this->_eventManager->dispatch('clean_cache_by_tags', ['object' => $product]);
  • Drawback: If the cron job did not run every day, the process breaks
    – Alex
    Commented Jan 22, 2019 at 16:21
  • Just have a look if time() is after news_to_date if true it's not new anymore
    – Daniel
    Commented Jan 22, 2019 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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