Blog Sections Open

Rotating a Product of the Day Every 24 Hours

A simple approach to rotating a featured product every day using a TV flag, a filtered product pool, and scheduled selection logic.

A common storefront task is a “Product of the Day” block that changes automatically every 24 hours. The usual first step is marking eligible products with a TV or checkbox field, but the next step is deciding how the actual rotation should happen.

Basic filtered list

The original setup often starts with a filtered one-item query:

[[!pdoPage?
    &parents=`2,3,4`
    &where=`{"template":"6"}`
    &tpl=`tpl.spec`
    &includeTVs=`typeimg,price_spec,price_old_spec,check_price`
    &limit=`1`
    &tvFilters=`check_price==1`
]]

This is a good pool definition, but by itself it does not guarantee a daily change. It simply returns one matching product according to the current sort order.

How to make the product rotate

You need one extra rule:

  • store the last selected product and selection date
  • or calculate a deterministic offset based on the current date
  • or run a scheduled task that writes the chosen product id into a setting or TV once per day

A practical pattern

The cleanest approach is usually:

  • mark eligible products with a TV such as check_price
  • once per day choose one id from that pool
  • save that id in a system setting or dedicated document field
  • render the selected product directly

This avoids accidental reshuffling on every request.

If you want deterministic rotation without storage

You can also order the eligible pool consistently and choose the item by date-based offset. For example, use the current day number modulo the number of eligible products. That gives you a daily rotation without writing state, although the exact sequence depends on the query order.

For promotions and storefront widgets, explicit daily selection is usually easier to control than purely random output.

Newer post

Creating Custom TVs in Evolution CMS

How to combine multiple form controls into one custom TV in Evolution CMS and store the result as a structured value.

Older post

Adding a YouTube Help Widget to the Evolution CMS Manager

An extras-style note showing how a manager plugin can embed a YouTube video or playlist on the dashboard so editors always have quick access to training material.