From 4f177847dc26064d5d57ddd55bd4e65d3b003df6 Mon Sep 17 00:00:00 2001 From: Stanislav Ilnytskyi Date: Tue, 5 Nov 2024 18:44:44 +0100 Subject: [PATCH] Allow custom catalog rule conditions --- .../Model/Rule/Condition/ConditionsToSearchCriteriaMapper.php | 4 ++-- .../Model/Rule/Condition/MappableConditionsProcessor.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/CatalogRule/Model/Rule/Condition/ConditionsToSearchCriteriaMapper.php b/app/code/Magento/CatalogRule/Model/Rule/Condition/ConditionsToSearchCriteriaMapper.php index 662a2fd6b38fc..83925ad59996b 100644 --- a/app/code/Magento/CatalogRule/Model/Rule/Condition/ConditionsToSearchCriteriaMapper.php +++ b/app/code/Magento/CatalogRule/Model/Rule/Condition/ConditionsToSearchCriteriaMapper.php @@ -82,9 +82,9 @@ public function mapConditionsToSearchCriteria(CombinedCondition $conditions): Se */ private function mapConditionToFilterGroup(ConditionInterface $condition) { - if ($condition->getType() === CombinedCondition::class) { + if ($condition instanceof CombinedCondition) { return $this->mapCombinedConditionToFilterGroup($condition); - } elseif ($condition->getType() === SimpleCondition::class) { + } elseif ($condition instanceof SimpleCondition) { return $this->mapSimpleConditionToFilterGroup($condition); } diff --git a/app/code/Magento/CatalogRule/Model/Rule/Condition/MappableConditionsProcessor.php b/app/code/Magento/CatalogRule/Model/Rule/Condition/MappableConditionsProcessor.php index 5ad3d383d0d2e..2fba1ac930e6e 100644 --- a/app/code/Magento/CatalogRule/Model/Rule/Condition/MappableConditionsProcessor.php +++ b/app/code/Magento/CatalogRule/Model/Rule/Condition/MappableConditionsProcessor.php @@ -67,7 +67,7 @@ private function rebuildCombinedCondition(CombinedCondition $originalConditions) $invalidConditions = []; foreach ($originalConditions->getConditions() as $condition) { - if ($condition->getType() === CombinedCondition::class) { + if ($condition instanceof CombinedCondition) { $rebuildSubCondition = $this->rebuildCombinedCondition($condition); if (count($rebuildSubCondition->getConditions()) > 0) { @@ -79,7 +79,7 @@ private function rebuildCombinedCondition(CombinedCondition $originalConditions) continue; } - if ($condition->getType() === SimpleCondition::class) { + if ($condition instanceof SimpleCondition) { if ($this->validateSimpleCondition($condition)) { $validConditions[] = $condition; } else {