Skip to content

Price History

Module: Magenx_PriceHistoryGraphQl

The EU Omnibus Directive requires a shop that announces a price reduction to show the prior price: the lowest price in at least the 30 days before. Magento only knows today’s price. This module records a daily price history and gives the storefront the lowest price in the window, shown as “Lowest price in the last 30 days: €…”.

Lowest price in the last 30 days shown under a discounted price
Prior-price disclosure under a discounted product price.
daily snapshotlowest in window

Magento price index

Price history
per product, website,
customer group, day

ProductInterface.price_history

Product cards and page

  • A daily cron job copies each product’s current price from Magento’s price index.
  • One row is kept per product, website, customer group and day, because each customer group can see a different price.
  • If the snapshot runs twice in a day, the lower price is kept, so a same-day markdown is not lost.
  • For configurable, bundle and grouped products, the “from” price shown on the storefront is recorded. Each variant also has its own history, so choosing a swatch updates the disclosure.
  • Old rows are removed automatically, so the history doesn’t keep growing.
  • Run the snapshot after the price reindex. It is only as fresh as the last price index. If the price indexer runs on a schedule, keep the snapshot after it (default 03:00).
  • Database size. About products × websites × customer groups × (window + 10 days) rows. It stays flat once the window is full.
  • The snapshot is skipped while the feature is off everywhere, so an unused install records nothing.

Nightly capture

  1. After prices are recalculated, a job stores each product's price for every website and customer group, in batches.
  2. Running again on the same day keeps the lower value.
  3. Snapshots older than the longest window + 10 days are removed.

Shopper sees a discount

  1. A list requests prior prices for its products.
  2. Each product returns lowest price, currency, window days and start date, or nothing.
  3. Where the current price is lower, the storefront shows "Lowest price in the last 30 days: …".

Variant selection

  1. Selecting a variant shows that variant's own prior price.

These always hold:

  • The prior price is never higher than any price captured in the window for that website and group.
  • A prior price of 0 is never returned.
  • One customer group's prices never affect another group's prior price.
  • Prior price = minimum of positive snapshots with day ≥ today − window, for website and group.
  • Days and windows use the anchor time zone for capture and read alike.
  • Retention = longest window in use + 10 days.
  • A same-day markdown captured by a re-run is kept.
  • After switching off, storage drains through pruning.
SituationWhat happens
Product with variants (own price 0, "from" 49).49 captured.
Free product (0 / 0).Not captured.
Old 0.00 snapshot exists.Ignored.
One store view uses 90 days, the rest 30.100 days kept.
Wholesale group sees 80, general 100.Each group gets its own prior price.
Store view time zone differs from the anchor.Window boundaries follow the anchor.
Only 3 days of data so far.Minimum of those 3 days.
  • Every product with a calculated price; store views with tracking on.
  • Deciding when a price counts as a "reduction" (the storefront compares).
  • History from before the feature was switched on.
  • Price charts or full history.
  • Intraday tracking beyond keeping each day's lowest price.
Terminal window
composer require magenxcommerce/module-price-history-graph-ql
bin/magento module:enable Magenx_PriceHistoryGraphQl
bin/magento setup:upgrade
bin/magento setup:di:compile # production mode only
bin/magento cache:flush
  • PHP ~8.4.0||~8.5.0, Magento 2.4.8.

Stores > Configuration > Magenx > Price History (EU Omnibus)

General

Records a daily snapshot of each product's price and exposes the lowest price over the look-back window as the EU Omnibus "prior price" (the lowest price applied during at least the 30 days before a reduction, which must be shown whenever a reduction is announced). Needs the magenx_price_history_snapshot cron running; the window fills in over the first N days. When disabled the price_history product field resolves to null and the storefront shows no prior-price line.

SettingDefaultScopeNotes
Enable Prior-Price Tracking
magenx_price_history/general/enabled
NoStore viewYes/No.
Look-back Window (days)
magenx_price_history/general/window_days
30Store viewText. Shown when Enable Prior-Price Tracking = Yes. The prior price is the lowest price over this many days. EU Omnibus requires at least 30.

Cron

SettingDefaultScopeNotes
Snapshot Schedule (cron expression)
magenx_price_history/cron/schedule
0 3 * * *GlobalText. When the daily price snapshot runs. Default "0 3 * * *". Schedule it after the product price reindex so it captures the day's real prices.

Grant these under System > Permissions > User Roles > Role Resources:

ResourceUnderID
Price History SectionStores > Settings > ConfigurationMagenx_PriceHistoryGraphQl::config
JobGroupDefault scheduleChange it at
magenx_price_history_snapshotdefault0 3 * * *magenx_price_history/cron/schedule

ProductInterface.price_history resolves a whole grid in one query, so it is safe on category and search pages. It is null when the feature is off or no history exists yet.

Fields added to Magento types

FieldTypeDescription
ProductInterface.price_historyPriceHistoryEU Omnibus prior price: the lowest price applied to this product over the configured look-back window (default 30 days), for the request's website + customer group. Null when the feature is disabled or no history has been captured yet. Resolved in a single batched query per request, so it is safe on listing grids.
StoreConfig.price_history_enabledBooleanWhether EU Omnibus prior-price tracking is enabled for the store.

Types

type PriceHistory - EU Omnibus (Art. 6a of Directive 98/6/EC) prior-price information: the lowest price applied over the look-back window, which must be shown alongside any announced price reduction.
FieldTypeDescription
lowest_priceFloatThe lowest price applied during the look-back window, in the store's display currency.
currencyStringCurrency code of lowest_price.
daysIntLength of the look-back window in days.
sinceStringISO-8601 date (YYYY-MM-DD) the window starts, i.e. today minus days.
TermMeaning
SnapshotOne captured price per product, website, customer group and day.
WindowLook-back days (default 30, the EU minimum).
Prior priceLowest positive snapshot inside the window for the shopper's website and group.
Selling priceSingle-unit price after special prices and catalog promotions.
"From" priceFor products with variants: the cheapest variant's price.
Anchor time zoneOne fixed time zone used for days and windows everywhere.