Skip to content

Commit 7d5c6c4

Browse files
committed
ACP2E-2494: Performance issue when loading product attributes in cart rules
- testing PAT
1 parent cfa9b55 commit 7d5c6c4

File tree

1 file changed

+6
-6
lines changed
  • app/code/Magento/SalesRule/Model/ResourceModel

1 file changed

+6
-6
lines changed

app/code/Magento/SalesRule/Model/ResourceModel/Rule.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305,17 +305,17 @@ public function getStoreLabel($ruleId, $storeId)
305305
public function getActiveAttributes()
306306
{
307307
$connection = $this->getConnection();
308-
$subSelect = $connection->select();
309-
$subSelect->reset();
310-
$subSelect->from($this->getTable('salesrule_product_attribute'))
311-
->group('attribute_id');
312308
$select = $connection->select()->from(
313-
['a' => $subSelect],
314-
new \Zend_Db_Expr('ea.attribute_code')
309+
['a' => $this->getTable('salesrule_product_attribute')],
310+
new \Zend_Db_Expr('DISTINCT ea.attribute_code')
315311
)->joinInner(
316312
['ea' => $this->getTable('eav_attribute')],
317313
'ea.attribute_id = a.attribute_id',
318314
[]
315+
)->joinInner(
316+
['sr' => $this->getTable('salesrule')],
317+
'a.' . $this->getLinkField() . ' = sr.' . $this->getLinkField() . ' AND sr.is_active = 1',
318+
[]
319319
);
320320

321321
return $connection->fetchAll($select);

0 commit comments

Comments
 (0)