Skip to content

Commit b91b4cc

Browse files
committed
ACP2E-331: For products that do not have a category, the catalog price rule fails on condition, not in specific category.
1 parent 1ef4504 commit b91b4cc

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

app/code/Magento/Catalog/Model/Api/SearchCriteria/CollectionProcessor/ConditionProcessor/ProductCategoryCondition.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Magento\Framework\Api\SearchCriteria\CollectionProcessor\ConditionProcessor\CustomConditionInterface;
1111
use Magento\Catalog\Model\ResourceModel\Product\Collection;
1212
use Magento\Framework\Api\Filter;
13-
use Magento\Framework\Data\Collection\AbstractDb;
1413
use Magento\Framework\Exception\NoSuchEntityException as CategoryDoesNotExistException;
1514

1615
/**
@@ -63,12 +62,12 @@ public function build(Filter $filter): string
6362
)->where(
6463
$this->resourceConnection->getConnection()->prepareSqlCondition(
6564
'cat.category_id',
66-
[$this->mapConditionType($filter->getConditionType()) => $this->getCategoryIds($filter)]
65+
['in' => $this->getCategoryIds($filter)]
6766
)
6867
);
6968

7069
$selectCondition = [
71-
'in' => $categorySelect
70+
$this->mapConditionType($filter->getConditionType()) => $categorySelect
7271
];
7372

7473
return $this->resourceConnection->getConnection()
@@ -116,12 +115,7 @@ private function getCategoryIds(Filter $filter): array
116115
*/
117116
private function mapConditionType(string $conditionType): string
118117
{
119-
$conditionsMap = [
120-
'eq' => 'in',
121-
'neq' => 'nin',
122-
'like' => 'in',
123-
'nlike' => 'nin',
124-
];
125-
return $conditionsMap[$conditionType] ?? $conditionType;
118+
$ninConditions = ['nin', 'neq', 'nlike'];
119+
return in_array($conditionType, $ninConditions, true) ? 'nin' : 'in';
126120
}
127121
}

0 commit comments

Comments
 (0)