6
6
7
7
namespace Magento \SalesRule \Model \Rule \Condition ;
8
8
9
- use Magento \ConfigurableProduct \Model \Product \Type \Configurable ;
10
-
11
9
/**
12
10
* Product rule condition data model
13
11
*
@@ -31,34 +29,6 @@ protected function _addSpecialAttributes(array &$attributes)
31
29
$ attributes ['quote_item_row_total ' ] = __ ('Row total in cart ' );
32
30
}
33
31
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
-
62
32
/**
63
33
* Validate Product Rule Condition
64
34
*
@@ -71,7 +41,10 @@ public function validate(\Magento\Framework\Model\AbstractModel $model)
71
41
{
72
42
//@todo reimplement this method when is fixed MAGETWO-5713
73
43
/** @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
+ }
75
48
76
49
$ product ->setQuoteItemQty (
77
50
$ model ->getQty ()
0 commit comments