diff --git a/vendor/magento/module-advanced-rule/Model/Condition/Filter.php b/vendor/magento/module-advanced-rule/Model/Condition/Filter.php
index 254f29320312..004f8feff27a 100644
--- a/vendor/magento/module-advanced-rule/Model/Condition/Filter.php
+++ b/vendor/magento/module-advanced-rule/Model/Condition/Filter.php
@@ -8,19 +8,20 @@
use Magento\AdvancedRule\Model\Condition\FilterInterface;
/**
- * Class Filter
+ * Class to save Filter related logic for rules into database.
*
* @codeCoverageIgnore
*/
class Filter extends \Magento\Framework\Model\AbstractModel implements FilterInterface
{
- const KEY_FILTER_TEXT = 'filter_text';
- const KEY_WEIGHT = 'weight';
- const KEY_FILTER_TEXT_GENERATOR_CLASS = 'filter_text_generator_class';
- const KEY_FILTER_TEXT_GENERATOR_ARGUMENTS = 'filter_text_generator_arguments';
+ public const KEY_FILTER_TEXT = 'filter_text';
+ public const KEY_WEIGHT = 'weight';
+ public const KEY_FILTER_TEXT_GENERATOR_CLASS = 'filter_text_generator_class';
+ public const KEY_FILTER_TEXT_GENERATOR_ARGUMENTS = 'filter_text_generator_arguments';
+ public const IS_COUPON = 'is_coupon';
/**
- * @return string
+ * @inheritdoc
*/
public function getFilterText()
{
@@ -28,8 +29,7 @@ public function getFilterText()
}
/**
- * @param string $filterText
- * @return $this
+ * @inheritdoc
*/
public function setFilterText($filterText)
{
@@ -37,7 +37,7 @@ public function setFilterText($filterText)
}
/**
- * @return float
+ * @inheritdoc
*/
public function getWeight()
{
@@ -45,8 +45,7 @@ public function getWeight()
}
/**
- * @param float $weight
- * @return $this
+ * @inheritdoc
*/
public function setWeight($weight)
{
@@ -54,9 +53,7 @@ public function setWeight($weight)
}
/**
- * Return name of the FilterTextGenerator class
- *
- * @return string
+ * @inheritdoc
*/
public function getFilterTextGeneratorClass()
{
@@ -64,8 +61,7 @@ public function getFilterTextGeneratorClass()
}
/**
- * @param string $filterTextGeneratorClass
- * @return $this
+ * @inheritdoc
*/
public function setFilterTextGeneratorClass($filterTextGeneratorClass)
{
@@ -73,7 +69,7 @@ public function setFilterTextGeneratorClass($filterTextGeneratorClass)
}
/**
- * @return string
+ * @inheritdoc
*/
public function getFilterTextGeneratorArguments()
{
@@ -81,11 +77,26 @@ public function getFilterTextGeneratorArguments()
}
/**
- * @param string $arguments
- * @return $this
+ * @inheritdoc
*/
public function setFilterTextGeneratorArguments($arguments)
{
return $this->setData(self::KEY_FILTER_TEXT_GENERATOR_ARGUMENTS, $arguments);
}
+
+ /**
+ * @inheritdoc
+ */
+ public function setIsCoupon(bool $isCoupon)
+ {
+ return $this->setData(self::IS_COUPON, $isCoupon);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function isCoupon():bool
+ {
+ return $this->getData(self::IS_COUPON);
+ }
}
diff --git a/vendor/magento/module-advanced-rule/Model/Condition/FilterInterface.php b/vendor/magento/module-advanced-rule/Model/Condition/FilterInterface.php
index 3436599537c7..cdd328fcfb44 100644
--- a/vendor/magento/module-advanced-rule/Model/Condition/FilterInterface.php
+++ b/vendor/magento/module-advanced-rule/Model/Condition/FilterInterface.php
@@ -14,51 +14,83 @@
*/
interface FilterInterface
{
- const FILTER_TEXT_TRUE = 'true';
+ /**
+ * Const to show if filter is text.
+ */
+ public const FILTER_TEXT_TRUE = 'true';
/**
+ * Return filter text.
+ *
* @return string
*/
public function getFilterText();
/**
+ * Set filter text.
+ *
* @param string $filterText
* @return $this
*/
public function setFilterText($filterText);
/**
+ * Return weight of the rule to see if it can be applied.
+ *
* @return float
*/
public function getWeight();
/**
+ * Set weight of the rule to see if it can be applied.
+ *
* @param float $weight
* @return $this
*/
public function setWeight($weight);
/**
- * Return name of the FilterTextGenerator class
+ * Return name of the FilterTextGenerator class.
*
* @return string
*/
public function getFilterTextGeneratorClass();
/**
+ * Set name of the FilterTextGenerator class.
+ *
* @param string $filterTextGeneratorClass
* @return $this
*/
public function setFilterTextGeneratorClass($filterTextGeneratorClass);
/**
+ * Return arguments for FilterTextGenerator class.
+ *
* @return string
*/
public function getFilterTextGeneratorArguments();
/**
+ * Set arguments for FilterTextGenerator class.
+ *
* @param string $arguments
* @return $this
*/
public function setFilterTextGeneratorArguments($arguments);
+
+ /**
+ * Set flag if a rule is coupon based.
+ *
+ * @param bool $isCoupon
+ * @return $this
+ */
+ public function setIsCoupon(bool $isCoupon);
+
+ /**
+ * Return flag if coupon is rule based.
+ *
+ * @return bool
+ */
+ public function isCoupon():bool;
}
diff --git a/vendor/magento/module-advanced-sales-rule/Model/Indexer/SalesRule/AbstractAction.php b/vendor/magento/module-advanced-sales-rule/Model/Indexer/SalesRule/AbstractAction.php
index 9ea9d5f8edb0..d720c123b119 100644
--- a/vendor/magento/module-advanced-sales-rule/Model/Indexer/SalesRule/AbstractAction.php
+++ b/vendor/magento/module-advanced-sales-rule/Model/Indexer/SalesRule/AbstractAction.php
@@ -54,12 +54,14 @@ public function __construct(
/**
* Run full reindex
+ *
* @return $this
*/
abstract public function execute();
/**
- * Run reindexation
+ * Run reindexation.
+ *
* @param bool $fullReindex
* @return void
*/
@@ -79,6 +81,8 @@ protected function reindex($fullReindex = false)
}
/**
+ * Set ids for action.
+ *
* @param int[] $actionIds
* @return void
*/
@@ -88,6 +92,8 @@ protected function setActionIds($actionIds)
}
/**
+ * Save filters for specific rule.
+ *
* @param SalesRule $rule
* @return void
*/
@@ -96,6 +102,7 @@ protected function saveFilters(SalesRule $rule)
$ruleId = $rule->getId();
if ($ruleId) {
$condition = $rule->getConditions();
+ $isCouponCode = $rule->getCouponType() != SalesRule::COUPON_TYPE_NO_COUPON;
$data = [];
if ($condition instanceof FilterableConditionInterface && $condition->isFilterable()) {
$filterGroups = $condition->getFilterGroups();
@@ -110,6 +117,7 @@ protected function saveFilters(SalesRule $rule)
Filter::KEY_FILTER_TEXT => $filter->getFilterText(),
Filter::KEY_FILTER_TEXT_GENERATOR_CLASS => $filter->getFilterTextGeneratorClass(),
Filter::KEY_FILTER_TEXT_GENERATOR_ARGUMENTS => $filter->getFilterTextGeneratorArguments(),
+ Filter::IS_COUPON => $isCouponCode,
];
}
$groupId++;
@@ -118,6 +126,7 @@ protected function saveFilters(SalesRule $rule)
if (empty($data)) {
$data = $this->getTruePlaceHolder($ruleId);
+ $data[Filter::IS_COUPON] = $isCouponCode;
}
$this->filterResourceModel->insertFilters($data);
@@ -125,6 +134,8 @@ protected function saveFilters(SalesRule $rule)
}
/**
+ * Get placeholder for rules without data.
+ *
* @param int $ruleId
* @return array
*/
@@ -137,7 +148,6 @@ protected function getTruePlaceHolder($ruleId)
Filter::KEY_FILTER_TEXT => FilterInterface::FILTER_TEXT_TRUE,
Filter::KEY_FILTER_TEXT_GENERATOR_CLASS => null,
Filter::KEY_FILTER_TEXT_GENERATOR_ARGUMENTS => null,
-
];
}
}
diff --git a/vendor/magento/module-advanced-sales-rule/Model/ResourceModel/Rule/Condition/Filter.php b/vendor/magento/module-advanced-sales-rule/Model/ResourceModel/Rule/Condition/Filter.php
index 3d98979b41f9..8c4385ce90ae 100644
--- a/vendor/magento/module-advanced-sales-rule/Model/ResourceModel/Rule/Condition/Filter.php
+++ b/vendor/magento/module-advanced-sales-rule/Model/ResourceModel/Rule/Condition/Filter.php
@@ -56,6 +56,8 @@ public function filterRules(array $filterText)
$select = $connection->select()->from(
$this->getMainTable(),
['rule_id']
+ )->where(
+ 'is_coupon != 1',
)->where(
$connection->quoteInto(
FilterModel::KEY_FILTER_TEXT . ' IN (?) ',
diff --git a/vendor/magento/module-advanced-sales-rule/Model/Rule/Condition/FilterTextGenerator/Product/Category.php b/vendor/magento/module-advanced-sales-rule/Model/Rule/Condition/FilterTextGenerator/Product/Category.php
index 3e28264ecca0..a5876195ea85 100644
--- a/vendor/magento/module-advanced-sales-rule/Model/Rule/Condition/FilterTextGenerator/Product/Category.php
+++ b/vendor/magento/module-advanced-sales-rule/Model/Rule/Condition/FilterTextGenerator/Product/Category.php
@@ -1,16 +1,48 @@
productCategoryList = $categoryList ?: ObjectManager::getInstance()->get(ProductCategoryList::class);
+ }
+
+ /**
+ * Generates an array of filter text strings based on the categories of products in a given quote address.
+ *
* @param \Magento\Framework\DataObject $quoteAddress
* @return string[]
*/
@@ -21,7 +53,7 @@ public function generateFilterText(\Magento\Framework\DataObject $quoteAddress)
$items = $quoteAddress->getAllItems();
foreach ($items as $item) {
$product = $item->getProduct();
- $categoryIds = $product->getAvailableInCategories();
+ $categoryIds = $this->productCategoryList->getCategoryIds($product->getId());
foreach ($categoryIds as $categoryId) {
$text = Categories::FILTER_TEXT_PREFIX . $categoryId;
if (!in_array($text, $filterText)) {
diff --git a/vendor/magento/module-advanced-sales-rule/etc/db_schema.xml b/vendor/magento/module-advanced-sales-rule/etc/db_schema.xml
index cabb9d9bc3a8..d554aaef67a4 100644
--- a/vendor/magento/module-advanced-sales-rule/etc/db_schema.xml
+++ b/vendor/magento/module-advanced-sales-rule/etc/db_schema.xml
@@ -21,6 +21,8 @@
comment="Filter text generator class name"/>
+