LowestPriceLogger (optional)

https://github.com/magesuite/lowest-price-logger

The module was developed in order to be compliant with the “OMNIBUS” directive of the EU parliament.

 

Installation

This module is optional.

composer require "creativestyle/magesuite-lowest-price-logger" ^1.0.0

Admin settings

There is a new tab in the product form called Price History Log:

 

Backend

The documentation should be reviewed - moved from https://creativestyle.atlassian.net/wiki/spaces/CSHOP/pages/2183168017

Module by default logs two prices:

  • Regular price - normally used to display a strikethrough price

  • Final price - the lowest available price that the customer pays in the shop

 

Logging is done using two different methods:

  1. A Cron job runs at night and generates prices for all products, websites, and customer groups

  2. When customers enter any frontend page that displays prices, regular and final prices generated using Magento\Framework\Pricing\Price\PriceInterface are gathered and logged in batch into the database.

Prices are only stored in the log when there is an actual change compared to the last logged value for specified product id, website id, and customer group id.

If price has not changed for multiple days, there will be only one entry in the table with the date of the earliest log of that price.

Data cleanup

Data cleanup happens automatically and by default clears entries older than 30 days.

Accessing the lowest price from the last 30 days in PHTML templates

Collections

Data from the price history log is automatically added to products fetched from the collection.

The lowest price can be fetched in PHTML templates using \MageSuite\LowestPriceLogger\ViewModel\LowestPrice ViewModel by passing the product entity.

Fetching for a single product entity (for example on PDP)

Use \MageSuite\LowestPriceLogger\ViewModel\LowestPrice ViewModel. It will automatically fetch data from the database.

Per project customizations

In case the project uses any custom logic for prices/strikethrough prices it might be necessary to add custom code that will log additional price types/data from custom attributes.

The cron job that generates prices every night can be extended by creating plugins on \MageSuite\LowestPriceLogger\Model\GenerateLowestPriceForAllProducts class and extending addCustomPrices and processCollection methods with after plugins.

The frontend logger can be extended by creating a custom plugin. \MageSuite\LowestPriceLogger\Plugin\Framework\Pricing\Price\PriceInterface\LogPrice can be used as an example of such implementation.

The data collected using \MageSuite\LowestPriceLogger\Model\PriceStorage class will be automatically filtered out (to remove possible duplicates) and added in batch to the database almost at the end of a request.

 

Frontend

The is no frontend functionality in this module. The sibling module for displaying prices on the frontend is LowestPriceLoggerFrontend (optional)