Skip to content

Commit 962e897

Browse files
committed
ACP2E-3449: Slow query is executed when product widget is included via pagebuilder
1 parent 322f075 commit 962e897

File tree

1 file changed

+13
-5
lines changed
  • dev/tests/integration/testsuite/Magento/Rule/Model/Condition/Sql

1 file changed

+13
-5
lines changed

dev/tests/integration/testsuite/Magento/Rule/Model/Condition/Sql/BuilderTest.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,16 @@ public function testAttachConditionToCollection(
9999
);
100100
$multiselect->load('multi_select_attr', 'attribute_code');
101101
$multiselectAttributeOptionIds = [];
102+
$optionIndex = 1;
102103
foreach ($multiselect->getOptions() as $option) {
103104
if ($option->getValue()) {
104105
$multiselectAttributeOptionIds[] = $option->getValue();
106+
$expectedWhere = str_replace(
107+
"#optionAtrId$optionIndex#",
108+
$option->getValue(),
109+
$expectedWhere
110+
);
111+
$optionIndex++;
105112
}
106113
}
107114

@@ -205,11 +212,12 @@ public static function attachConditionToCollectionDataProvider(): array
205212
'collected_attributes' => ['multiselect_attribute' => true],
206213
]
207214
],
208-
"WHERE (((`e`.`entity_id` IN (SELECT `catalog_category_product`.`product_id` FROM " .
209-
"`catalog_category_product` WHERE (category_id IN ('3')))) " .
210-
"AND(`e`.`sku` IN ('sku1', 'sku2', 'sku3')) AND(`at_multi_select_attr`.`value` IN ('4', '5') OR " .
211-
"(FIND_IN_SET ('4', `at_multi_select_attr`.`value`) > 0) OR " .
212-
"(FIND_IN_SET ('5', `at_multi_select_attr`.`value`) > 0)) ))",
215+
"WHERE ((((`e`.`entity_id` IN (SELECT `catalog_category_product`.`product_id` FROM " .
216+
"`catalog_category_product` WHERE (category_id IN ('3')))) AND(`e`.`sku` IN " .
217+
"('sku1', 'sku2', 'sku3')) AND(`at_multi_select_attr`.`value` IN ('#optionAtrId1#', '#optionAtrId2#') OR " .
218+
"(FIND_IN_SET ('#optionAtrId1#', `at_multi_select_attr`.`value`) > 0) OR " .
219+
"(FIND_IN_SET ('#optionAtrId2#', `at_multi_select_attr`.`value`) > 0)) ))) AND " .
220+
"(e.created_in <= 1) AND (e.updated_in > 1)",
213221
"ORDER BY (FIELD(`e`.`sku`, 'sku1', 'sku2', 'sku3'))"
214222
]
215223
];

0 commit comments

Comments
 (0)