Closed
Description
Preconditions (*)
- Magento version: 2.2.8
- mysql 5.7
Steps to reproduce (*)
- Set an index on schedule ( ex: catalog_product_flat)
- update an attribute in the database with the same value as before
I use this query to set the same value as 10 rows has previously to test the trigger on Update.
INSERT INTO `catalog_product_entity_int` (`value_id`, `attribute_id`, `store_id`, `row_id`, `value`)
SELECT `value_id`, `attribute_id`, `store_id`, `row_id`, `value`
FROM catalog_product_entity_int as value_from LIMIT 10
ON DUPLICATE KEY UPDATE `value` = value_from.`value`;
UPDATE catalog_product_entity_int value_to
,(SELECT * FROM catalog_product_entity_int LIMIT 10) value_from
SET value_to.value = value_from.value
WHERE value_to.attribute_id = value_from.attribute_id
AND value_to.row_id = value_from.row_id
AND value_to.store_id = value_from.store_id
Expected result (*)
- The trigger related to the attribute shouldn't insert a line in the ChangeLog
_cl
table as the value didn't change.
here the update trigger oncatalog_product_entity_int
BEGIN
SET @entity_id = (SELECT `entity_id` FROM `catalog_product_entity` WHERE `row_id` = NEW.`row_id`);
IF (NEW.`value_id` <=> OLD.`value_id` OR NEW.`attribute_id` <=> OLD.`attribute_id` OR NEW.`store_id` <=> OLD.`store_id` OR NEW.`row_id` <=> OLD.`row_id` OR NEW.`value` <=> OLD.`value`) THEN INSERT IGNORE INTO `catalogsearch_fulltext_cl` (`entity_id`) values(@entity_id); END IF;
IF (NEW.`value_id` <=> OLD.`value_id` OR NEW.`attribute_id` <=> OLD.`attribute_id` OR NEW.`store_id` <=> OLD.`store_id` OR NEW.`row_id` <=> OLD.`row_id` OR NEW.`value` <=> OLD.`value`) THEN INSERT IGNORE INTO `catalog_product_flat_cl` (`entity_id`) values(@entity_id); END IF;
IF (NEW.`value_id` <=> OLD.`value_id` OR NEW.`attribute_id` <=> OLD.`attribute_id` OR NEW.`store_id` <=> OLD.`store_id` OR NEW.`row_id` <=> OLD.`row_id` OR NEW.`value` <=> OLD.`value`) THEN INSERT IGNORE INTO `catalog_product_category_cl` (`entity_id`) values(@entity_id); END IF;
IF (NEW.`value_id` <=> OLD.`value_id` OR NEW.`attribute_id` <=> OLD.`attribute_id` OR NEW.`store_id` <=> OLD.`store_id` OR NEW.`row_id` <=> OLD.`row_id` OR NEW.`value` <=> OLD.`value`) THEN INSERT IGNORE INTO `catalog_product_attribute_cl` (`entity_id`) values(@entity_id); END IF;
IF (NEW.`value_id` <=> OLD.`value_id` OR NEW.`attribute_id` <=> OLD.`attribute_id` OR NEW.`store_id` <=> OLD.`store_id` OR NEW.`row_id` <=> OLD.`row_id` OR NEW.`value` <=> OLD.`value`) THEN INSERT IGNORE INTO `bazaarvoice_product_cl` (`entity_id`) values(@entity_id); END IF;
IF (NEW.`value_id` <=> OLD.`value_id` OR NEW.`attribute_id` <=> OLD.`attribute_id` OR NEW.`store_id` <=> OLD.`store_id` OR NEW.`row_id` <=> OLD.`row_id` OR NEW.`value` <=> OLD.`value`) THEN INSERT IGNORE INTO `catalog_product_price_cl` (`entity_id`) values(@entity_id); END IF;
END
Actual result (*)
- The trigger related to the attribute insert a line in the ChangeLog
_cl
table
for examplecatalog_product_flat_cl
:
version_id | entity_id |
---|---|
1 | 1 |
2 | 3 |
3 | 4 |
4 | 5 |
5 | 7 |
6 | 8 |
7 | 11 |
8 | 18 |
9 | 20 |
10 | 22 |
11 | 1 |
12 | 3 |
13 | 4 |
14 | 5 |
15 | 7 |
16 | 8 |
17 | 11 |
18 | 18 |
19 | 20 |
20 | 22 |