In order to display rating stars and review count information in your site’s Klevu-driven product listings, the Magento application gathers and synchronizes review data for your products where available. To reduce the impact on sync operation times, this information is collated and stored by the application in real-time, and these cached values are sent as part of the product synchronization data whenever records are sent to Klevu for indexing.
The review data is stored in product attributes added by the Klevu module when the package is installed or upgraded.
This attribute will be visible when editing a product in Store scope only* and will be locked for editing to prevent its accidental use for unintended data.
It stores the average rating (as a value out of 100) for this product based on published reviews for the store selected, and its value is auto-populated by the Klevu plugin (see below).
Klevu Review Count
|Label||Klevu Review Count|
This attribute will be visible when editing a product in Store scope only and will be locked for editing to prevent its accidental use for unintended data.
It stores the total number of published reviews for this product for the store selected, regardless of whether they contain rating information, and its value is auto-populated by the Klevu plugin (see below)
How Ratings Data is Used by the Klevu Extension
The Klevu Rating attribute is sent as part of the product data in catalog synchronisation operations with the key rating. Before sending, the percentage value (0 - 100) is converted to a “rating stars” value (0 - 5)
The Rating attribute is also used (again, converted to “rating stars”) when sending some analytics data from the frontend, including product listing information when using Preserve Layout.
From v2.9.0 / 3.1.0 of the plugin, the Klevu Review Count information is sent as part of the product in catalog synchronisation operations with the key rating_count
How Ratings Data is Calculated by the Klevu Extension
Both Klevu Rating and Klevu Review Count information are calculated and saved in advance of being used in either the frontend or synchronisation operations. This will happen for individual products in real-time in reaction to events in the Magento workflow, but can also be triggered manually for the entire catalog.
When any of the following actions occur, rating and review count information will be calculated and saved for the associated product(s) across all applicable store views:
- A review is created
- A review is updated (including changing status; adding rating information)
- A review is deleted
- Magento reindexes rating information
To manually regenerate all ratings information for all store views, you can use the CLI command
php bin/magento klevu:rating --regenerate
Reviews are only considered when determining attribute values when they are in a published state, however calculation operations will take place regardless of a review’s status. This means that the product’s data will be regenerated whenever a new review is submitted in an unpublished state; unpublished reviews are deleted; etc. Usually this will not affect the calculated value, but will still update the rating data (resetting any values modified directly / through other plugins, or refreshing stale data).
The Klevu Rating will take an average of all reviews with rating attributes containing data, ignoring any others even if published while Klevu Review Count will use all published reviews.
For example, if you have added ratings in Magento after starting to collect reviews and have some legacy reviews without ratings, these will be ignored when calculating rating stars but will be included in the review count value.
Support for Non-Native Reviews
The Klevu extension only supports native Magento product reviews. If you are using a third-party or custom reviews provider or integration then that data will not be reflected in your search results without custom development.
Manually / Programmatically Updating Ratings Attribute Definitions
The attribute definitions for rating and review_count (from Klevu 2.9.0 /3.1.0) should not be modified at risk of causing errors on your site, both during frontend and synchronization operations.
If these attributes are deleted, the relevant data will omitted from both analytics or synchronisation calls until the attribute is recreated. Recreation of the attributes is not performed automatically by the module.
Manually / Programmatically Changing Ratings Attribute Data
If product data for either the rating or review_count attribute is updated outside the Klevu extension, it may cause errors or unexpected behaviour in your site - especially if the value entered is not numeric. This applies even if the attribute is deleted and recreated with an alternative definition.
Additionally, any time an event occurs which would regenerate the ratings data (see above), any changes you have made will be overwritten.
Copying Products / Creating New Stores
When copying a product (including copying product data to a newly created store), the Klevu product attributes' data will also be copied despite the new products having no associated reviews. When these new products are synced with Klevu, the original products' rating and review count information (at time of copying) will also be sent.
This copied data will be visible when editing the product in the relevant store view in the backend, but cannot be cleared manually as these fields are disabled (Note, In Klevu versions below 2.9.0 / 3.1.0, these attributes are available to modify but this is not recommended).
When a review, in any state, is associated with the new product / store view, the rating information will be updated automatically. You can also regenerate all ratings information for all store views using the following CLI command
php bin/magento klevu:rating --regenerate