Skip to content

Triggers created by MView are triggered all the time #23077

Closed
@sebastien-kathmandu

Description

@sebastien-kathmandu

Preconditions (*)

  1. Magento version: 2.2.8
  2. mysql 5.7

Steps to reproduce (*)

  1. Set an index on schedule ( ex: catalog_product_flat)
  2. 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 (*)

  1. 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 on catalog_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 (*)

  1. The trigger related to the attribute insert a line in the ChangeLog _cl table
    for example catalog_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

Metadata

Metadata

Labels

Issue: Format is validGate 1 Passed. Automatic verification of issue format passed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions