Skip to content

Commit

Permalink
#11897: Catalog product list widget not working with multiple sku
Browse files Browse the repository at this point in the history
  • Loading branch information
nmalevanec committed Dec 20, 2017
1 parent 8d62341 commit d5b596a
Showing 1 changed file with 4 additions and 29 deletions.
33 changes: 4 additions & 29 deletions app/code/Magento/Rule/Model/Condition/Product/AbstractProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,9 @@ public function getBindArgumentValue()
)->__toString()
);
} 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();
Expand Down Expand Up @@ -711,7 +713,7 @@ protected function _getAttributeSetId($productId)
public function getOperatorForValidate()
{
$operator = $this->getOperator();
if ($this->getInputType() == 'category' || $this->isMultipleSku()) {
if (in_array($this->getInputType(), ['category', 'sku'])) {
if ($operator == '==') {
$operator = '{}';
} elseif ($operator == '!=') {
Expand Down Expand Up @@ -760,31 +762,4 @@ private function removeTagsFromLabel(array $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 comments on commit d5b596a

Please sign in to comment.