public function testGetValueParsed()
 {
     $value = [1, 2, 3, 4, 5, 6, 7, 8, 9];
     $this->_condition->setValue(['1,2,3,4,5,6,7,8,9']);
     $this->_condition->setOperator('()');
     $this->assertEquals($value, $this->_condition->getValueParsed());
 }
Пример #2
0
 public function testGetMappedSqlField()
 {
     $this->_condition->setAttribute('category_ids');
     $this->assertEquals('category_ids', $this->_condition->getMappedSqlField());
 }
Пример #3
0
 /**
  * @param int $level
  * @return string
  */
 public function asStringRecursive($level = 0)
 {
     $str = parent::asStringRecursive($level);
     foreach ($this->getConditions() as $cond) {
         $str .= "\n" . $cond->asStringRecursive($level + 1);
     }
     return $str;
 }
Пример #4
0
 /**
  * Load array
  *
  * @param array $arr
  * @return \Magento\CatalogRule\Model\Rule\Condition\Product
  */
 public function loadArray($arr)
 {
     $this->setAttribute(isset($arr['attribute']) ? $arr['attribute'] : false);
     $attribute = $this->getAttributeObject();
     $isContainsOperator = !empty($arr['operator']) && in_array($arr['operator'], array('{}', '!{}'));
     if ($attribute && $attribute->getBackendType() == 'decimal' && !$isContainsOperator) {
         if (isset($arr['value'])) {
             if (!empty($arr['operator']) && in_array($arr['operator'], array('!()', '()')) && false !== strpos($arr['value'], ',')) {
                 $tmp = array();
                 foreach (explode(',', $arr['value']) as $value) {
                     $tmp[] = $this->localeFormat->getNumber($value);
                 }
                 $arr['value'] = implode(',', $tmp);
             } else {
                 $arr['value'] = $this->localeFormat->getNumber($arr['value']);
             }
         } else {
             $arr['value'] = false;
         }
         $arr['is_value_parsed'] = isset($arr['is_value_parsed']) ? $this->localeFormat->getNumber($arr['is_value_parsed']) : false;
     }
     return parent::loadArray($arr);
 }