Skip to content

Commit 6c73a6c

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

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');
308312
$select = $connection->select()->from(
309-
['a' => $this->getTable('salesrule_product_attribute')],
310-
new \Zend_Db_Expr('DISTINCT ea.attribute_code')
313+
['a' => $subSelect],
314+
new \Zend_Db_Expr('ea.attribute_code')
311315
)->joinInner(
312316
['ea' => $this->getTable('eav_attribute')],
313317
'ea.attribute_id = a.attribute_id',
314318
[]
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)