Skip to content

Commit 7320b6c

Browse files
author
Roman Ganin
committed
MAGETWO-39957: Catalog Price Rule does not apply to Group price
1 parent 2382298 commit 7320b6c

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,4 +432,14 @@ public function getAffectedFields($object)
432432

433433
return $data;
434434
}
435+
436+
/**
437+
* Get resource model instance
438+
*
439+
* @return \Magento\Catalog\Model\Resource\Product\Attribute\Backend\GroupPrice
440+
*/
441+
public function getResource()
442+
{
443+
return $this->_getResource();
444+
}
435445
}

app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ class IndexBuilder
8282
*/
8383
protected $batchCount;
8484

85+
/**
86+
* @var \Magento\Catalog\Model\Product
87+
*/
88+
protected $product;
89+
8590
/**
8691
* @param RuleCollectionFactory $ruleCollectionFactory
8792
* @param PriceCurrencyInterface $priceCurrency
@@ -612,6 +617,17 @@ protected function getRuleProductsStmt($websiteId, $productId = null)
612617
$select->where('rp.product_id=?', $productId);
613618
}
614619

620+
/**
621+
* Join group price to result
622+
*/
623+
$groupPriceAttr = $this->eavConfig->getAttribute(Product::ENTITY, 'group_price');
624+
$select->joinLeft(
625+
['gp' => $groupPriceAttr->getBackend()->getResource()->getMainTable()],
626+
'gp.entity_id=rp.product_id AND gp.customer_group_id=rp.customer_group_id AND '
627+
. $this->getReadAdapter()->getCheckSql('gp.website_id=0', 'TRUE', 'gp.website_id=rp.website_id'),
628+
'value'
629+
);
630+
615631
/**
616632
* Join default price and websites prices to result
617633
*/
@@ -653,7 +669,10 @@ protected function getRuleProductsStmt($websiteId, $productId = null)
653669
[]
654670
);
655671
$select->columns([
656-
'default_price' => $this->getReadAdapter()->getIfNullSql($tableAlias . '.value', 'pp_default.value'),
672+
'default_price' => $this->getReadAdapter()->getIfNullSql(
673+
'gp.value',
674+
$this->getReadAdapter()->getIfNullSql($tableAlias . '.value', 'pp_default.value')
675+
),
657676
]);
658677

659678
return $read->query($select);

0 commit comments

Comments
 (0)