Skip to content

Commit 5bf2a7b

Browse files
MAGETWO-62405: Ignoring product visibility for SalesRules
1 parent a37f51e commit 5bf2a7b

File tree

2 files changed

+9
-25
lines changed

2 files changed

+9
-25
lines changed

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

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ public function validate(\Magento\Framework\Model\AbstractModel $model)
518518
$attrCode = $this->getAttribute();
519519

520520
if ('category_ids' == $attrCode) {
521-
return $this->validateAttribute($this->getAvailableInCategories($model));
521+
return $this->validateAttribute($model->getAvailableInCategories($model));
522522
} elseif (!isset($this->_entityAttributeValues[$model->getId()])) {
523523
if (!$model->getResource()) {
524524
return false;
@@ -621,7 +621,7 @@ public function getMappedSqlField()
621621
public function validateByEntityId($productId)
622622
{
623623
if ('category_ids' == $this->getAttribute()) {
624-
$result = $this->validateAttribute($this->_getAvailableInCategoriesById($productId));
624+
$result = $this->validateAttribute($this->_getAvailableInCategories($productId));
625625
} elseif ('attribute_set_id' == $this->getAttribute()) {
626626
$result = $this->validateAttribute($this->_getAttributeSetId($productId));
627627
} else {
@@ -632,24 +632,13 @@ public function validateByEntityId($productId)
632632
return $result;
633633
}
634634

635-
/**
636-
* Retrieve category ids where product is available
637-
*
638-
* @param \Magento\Framework\Model\AbstractModel $model
639-
* @return array
640-
*/
641-
protected function getAvailableInCategories($model)
642-
{
643-
return $model->getAvailableInCategories();
644-
}
645-
646635
/**
647636
* Retrieve category ids where productId is available
648637
*
649638
* @param int $productId
650639
* @return array
651640
*/
652-
protected function _getAvailableInCategoriesById($productId)
641+
protected function _getAvailableInCategories($productId)
653642
{
654643
return $this->_productResource->getConnection()
655644
->fetchCol(

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,13 @@ public function validate(\Magento\Framework\Model\AbstractModel $model)
4949
$model->getBaseRowTotal()
5050
);
5151

52-
return parent::validate($product);
53-
}
52+
$attrCode = $this->getAttribute();
5453

55-
/**
56-
* Retrieve category ids where product is available
57-
*
58-
* @param \Magento\Framework\Model\AbstractModel $model
59-
* @return array
60-
*/
61-
protected function getAvailableInCategories($model)
62-
{
63-
return $this->_getAvailableInCategoriesById($model->getId());
54+
if ('category_ids' == $attrCode) {
55+
return $this->validateAttribute($this->_getAvailableInCategories($product));
56+
}
57+
58+
return parent::validate($product);
6459
}
6560

6661
/**

0 commit comments

Comments
 (0)