Skip to content

Moving and copying Magento product reviews

When running an ecommerce business, you’ll often find yourself having to create a new product when an essentially identical product is released with an updated SKU, or when switching from a Grouped to Configurable product. But what happens to the reviews you have accumulated on the old product? They’ll get lost, unless you move the reviews from the old product to the new, or you duplicate them…

Magento provides no easy way of doing this within the Admin UI, and as per usual the review’s data is strewn across multiple tables. However it’s not too painful to brew some custom SQL to do the job…

Move all Magento Product reviews from one product to another product

SET @old_id = 1694;
SET @new_id = 1751;
UPDATE m4g3_review SET `entity_pk_value` = @new_id WHERE `entity_pk_value` = @old_id;
UPDATE m4g3_review_entity_summary SET `entity_pk_value` = @new_id WHERE `entity_pk_value` = @old_id;
UPDATE m4g3_rating_option_vote SET entity_pk_value = @new_id WHERE entity_pk_value = @old_id;
UPDATE m4g3_rating_option_vote_aggregated SET entity_pk_value = @new_id WHERE entity_pk_value = @old_id;

Copy all Magento Product reviews from one product to another product

SET @old_id = 1634;
SET @new_id = 1637;
INSERT INTO m4g3_review ( `created_at`, `entity_id`, `entity_pk_value`, `status_id` ) (
SELECT `created_at`, `entity_id`, @new_id AS `entity_pk_value`, `status_id` FROM `m4g3_review` WHERE `entity_pk_value` = @old_id

INSERT INTO m4g3_review_entity_summary ( `entity_pk_value`, `entity_type`, `reviews_count`, `rating_summary`, `store_id` ) (
SELECT @new_id AS `entity_pk_value`, `entity_type`, `reviews_count`, `rating_summary`, `store_id` FROM `m4g3_review_entity_summary` WHERE `entity_pk_value` = @old_id

INSERT INTO m4g3_rating_option_vote ( `option_id`, `remote_ip`, `remote_ip_long`, `customer_id`, `entity_pk_value`, `rating_id`, `review_id`, `percent`, `value` ) (
SELECT `option_id`, `remote_ip`, `remote_ip_long`, `customer_id`, @new_id AS `entity_pk_value`, `rating_id`, `review_id`, `percent`, `value` FROM `m4g3_rating_option_vote` WHERE `entity_pk_value` = @old_id

INSERT INTO m4g3_rating_option_vote_aggregated ( `rating_id`, `entity_pk_value`, `vote_count`, `vote_value_sum`, `percent`, `percent_approved`, `store_id` ) (
SELECT `rating_id`, @new_id AS `entity_pk_value`, `vote_count`, `vote_value_sum`, `percent`, `percent_approved`, `store_id` FROM `m4g3_rating_option_vote_aggregated` WHERE `entity_pk_value` = @old_id

Need some help managing your Magento ecommerce store? Give us a call on 01380 830224 and we’ll see what we can do to ease your pain… 

This entry was posted in Magento, Web Development. Bookmark the permalink.


Sorry, comments are closed on this page.