66
77namespace 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