示例#1
0
 /**
  * @dataProvider attributeValueDataProvider
  */
 public function testValidate($data)
 {
     $this->_attribute->expects($this->atLeastOnce())->method('getAttributeCode')->will($this->returnValue('code'));
     $product = new Varien_Object(array('code' => $data));
     $this->_model->validate($product);
     $this->assertEquals('1,2,3', $product->getCode());
 }
示例#2
0
 public function beforeSave($object)
 {
     $data = $object->getData($this->getAttribute()->getAttributeCode());
     if (!isset($data)) {
         $data = array();
     } elseif (is_string($data)) {
         $data = explode(',', $data);
     } elseif (!is_array($data)) {
         $data = array();
     }
     $object->setData($this->getAttribute()->getAttributeCode(), $data);
     /**
      * Mage_Eav_Model_Entity_Attribute_Backend_Array::beforeSave() makes a string from the array values
      */
     return parent::beforeSave($object);
 }