Skip to content

Commit 5b95b22

Browse files
committed
#14020-Cart-Sales-Rule-with-negated-condition-over-special-price-does-not-work-for-configurable-products.
Restored \Magento\SalesRule\Model\Rule\Condition\Product to its previous state except PHPDocs.
1 parent 4e68337 commit 5b95b22

File tree

1 file changed

+4
-31
lines changed
  • app/code/Magento/SalesRule/Model/Rule/Condition

1 file changed

+4
-31
lines changed

app/code/Magento/SalesRule/Model/Rule/Condition/Product.php

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
namespace Magento\SalesRule\Model\Rule\Condition;
88

9-
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
10-
119
/**
1210
* Product rule condition data model
1311
*
@@ -31,34 +29,6 @@ protected function _addSpecialAttributes(array &$attributes)
3129
$attributes['quote_item_row_total'] = __('Row total in cart');
3230
}
3331

34-
/**
35-
* @param \Magento\Framework\Model\AbstractModel $model
36-
*
37-
* @return \Magento\Catalog\Api\Data\ProductInterface|\Magento\Catalog\Model\Product
38-
* @throws \Magento\Framework\Exception\NoSuchEntityException
39-
*/
40-
private function getProductToValidate(\Magento\Framework\Model\AbstractModel $model)
41-
{
42-
/** @var \Magento\Catalog\Model\Product $product */
43-
$product = $model->getProduct();
44-
if (!$product instanceof \Magento\Catalog\Model\Product) {
45-
$product = $this->productRepository->getById($model->getProductId());
46-
}
47-
48-
$attrCode = $this->getAttribute();
49-
50-
/* Check for attributes which are not available for configurable products */
51-
if ($product->getTypeId() == Configurable::TYPE_CODE && !$product->hasData($attrCode)) {
52-
/** @var \Magento\Catalog\Api\Data\ProductInterface $childProduct */
53-
$childProduct = current($model->getChildren())->getProduct();
54-
if ($childProduct->hasData($attrCode)) {
55-
$product = $childProduct;
56-
}
57-
}
58-
59-
return $product;
60-
}
61-
6232
/**
6333
* Validate Product Rule Condition
6434
*
@@ -71,7 +41,10 @@ public function validate(\Magento\Framework\Model\AbstractModel $model)
7141
{
7242
//@todo reimplement this method when is fixed MAGETWO-5713
7343
/** @var \Magento\Catalog\Model\Product $product */
74-
$product = $this->getProductToValidate($model);
44+
$product = $model->getProduct();
45+
if (!$product instanceof \Magento\Catalog\Model\Product) {
46+
$product = $this->productRepository->getById($model->getProductId());
47+
}
7548

7649
$product->setQuoteItemQty(
7750
$model->getQty()

0 commit comments

Comments
 (0)