Skip to content
Snippets Groups Projects
Commit d5b596a1 authored by nmalevanec's avatar nmalevanec
Browse files

magento/magento2#11897: Catalog product list widget not working with multiple sku

parent 8d623412
Branches
No related merge requests found
...@@ -611,7 +611,9 @@ abstract class AbstractProduct extends \Magento\Rule\Model\Condition\AbstractCon ...@@ -611,7 +611,9 @@ abstract class AbstractProduct extends \Magento\Rule\Model\Condition\AbstractCon
)->__toString() )->__toString()
); );
} elseif ($this->getAttribute() === 'sku') { } elseif ($this->getAttribute() === 'sku') {
$this->isMultipleSku(); $value = $this->getData('value');
$value = preg_split('#\s*[,;]\s*#', $value, null, PREG_SPLIT_NO_EMPTY);
$this->setValueParsed($value);
} }
return parent::getBindArgumentValue(); return parent::getBindArgumentValue();
...@@ -711,7 +713,7 @@ abstract class AbstractProduct extends \Magento\Rule\Model\Condition\AbstractCon ...@@ -711,7 +713,7 @@ abstract class AbstractProduct extends \Magento\Rule\Model\Condition\AbstractCon
public function getOperatorForValidate() public function getOperatorForValidate()
{ {
$operator = $this->getOperator(); $operator = $this->getOperator();
if ($this->getInputType() == 'category' || $this->isMultipleSku()) { if (in_array($this->getInputType(), ['category', 'sku'])) {
if ($operator == '==') { if ($operator == '==') {
$operator = '{}'; $operator = '{}';
} elseif ($operator == '!=') { } elseif ($operator == '!=') {
...@@ -760,31 +762,4 @@ abstract class AbstractProduct extends \Magento\Rule\Model\Condition\AbstractCon ...@@ -760,31 +762,4 @@ abstract class AbstractProduct extends \Magento\Rule\Model\Condition\AbstractCon
return $selectOptions; return $selectOptions;
} }
/**
* Check condition contains multiple sku.
*
* @return bool
*/
private function isMultipleSku()
{
$result = false;
if ($this->getInputType() === 'sku') {
if ($this->hasValueParsed()) {
$value = $this->getData('value_parsed');
if (count($value > 1)) {
$result = true;
}
} else {
$value = $this->getData('value');
$value = preg_split('#\s*[,;]\s*#', $value, null, PREG_SPLIT_NO_EMPTY);
if (count($value > 1)) {
$this->setValueParsed($value);
$result = true;
}
}
}
return $result;
}
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment