public function addData(array $data)
 {
     if (isset($data['name']) && strpos($data['name'], 'a:') !== 0) {
         $this->setName($data['name']);
         unset($data['name']);
     }
     return parent::addData($data);
 }
 public function addData(array $data)
 {
     if (isset($data['name']) && strpos($data['name'], 'a:') !== 0) {
         $this->setName($data['name']);
         unset($data['name']);
     }
     if (isset($data['description']) && strpos($data['description'], 'a:') !== 0) {
         $this->setDescription($data['description']);
         unset($data['description']);
     }
     if (isset($data['values']) && strpos($data['values'], 'a:') !== 0) {
         $this->setValues($data['values']);
         unset($data['values']);
     }
     return parent::addData($data);
 }
Пример #3
0
 protected function _afterLoad(Mage_Core_Model_Abstract $object)
 {
     if ($object->getId()) {
         $read = $this->_getReadAdapter();
         if ($object->getType() == BL_CustomGrid_Model_Options_Source::SOURCE_TYPE_MAGE_MODEL) {
             // Load corresponding model
             $query = $read->select()->from($this->getTable('customgrid/options_source_model'))->where('source_id = ?', $object->getId());
             if ($model = $read->fetchRow($query)) {
                 $object->addData($model);
             }
         } else {
             // Load corresponding options
             $query = $read->select()->from($this->getTable('customgrid/options_source_option'))->where('source_id = ?', $object->getId());
             $options = $read->fetchAll($query);
             $object->setData('options', is_array($options) ? $options : array());
         }
     }
     return parent::_afterLoad($object);
 }
Пример #4
0
 /**
  * Attach extended data to sales object
  *
  * @param Mage_Core_Model_Abstract $sales
  * @return Enterprise_Customer_Model_Sales_Abstract
  */
 public function attachAttributeData(Mage_Core_Model_Abstract $sales)
 {
     $sales->addData($this->getData());
     return $this;
 }
Пример #5
0
 /**
  * Update field in table if model have been already saved
  *
  * @param Mage_Core_Model_Abstract $object
  * @param array $data
  * @return Mage_Sales_Model_Resource_Order_Abstract
  */
 protected function _postSaveFieldsUpdate($object, $data)
 {
     if ($object->getId() && !empty($data)) {
         $table = $this->getMainTable();
         $this->_getWriteAdapter()->update($table, $data, array($this->getIdFieldName() . '=?' => (int) $object->getId()));
         $object->addData($data);
     }
     return $this;
 }
Пример #6
0
 /**
  * Load additional attribute data.
  * Load label of current active store
  *
  * @param Mage_Eav_Model_Entity_Attribute|Mage_Core_Model_Abstract $object
  * @return Mage_Eav_Model_Resource_Entity_Attribute
  */
 protected function _afterLoad(Mage_Core_Model_Abstract $object)
 {
     /** @var $entityType Mage_Eav_Model_Entity_Type */
     $entityType = $object->getData('entity_type');
     if ($entityType) {
         $additionalTable = $entityType->getAdditionalAttributeTable();
     } else {
         $additionalTable = $this->getAdditionalAttributeTable($object->getEntityTypeId());
     }
     if ($additionalTable) {
         $adapter = $this->_getReadAdapter();
         $bind = array(':attribute_id' => $object->getId());
         $select = $adapter->select()->from($this->getTable($additionalTable))->where('attribute_id = :attribute_id');
         $result = $adapter->fetchRow($select, $bind);
         if ($result) {
             $object->addData($result);
         }
     }
     return $this;
 }
Пример #7
0
 /**
  * Load additional attribute data.
  * Load label of current active store
  *
  * @param Varien_Object $object
  * @return Mage_Eav_Model_Mysql4_Entity_Attribute
  */
 protected function _afterLoad(Mage_Core_Model_Abstract $object)
 {
     if ($entityType = $object->getData('entity_type')) {
         $additionalTable = $entityType->getAdditionalAttributeTable();
     } else {
         $additionalTable = $this->getAdditionalAttributeTable($object->getEntityTypeId());
     }
     if ($additionalTable) {
         $select = $this->_getReadAdapter()->select()->from($this->getTable($additionalTable))->where('attribute_id = ?', $object->getId());
         if ($result = $this->_getReadAdapter()->fetchRow($select)) {
             $object->addData($result);
         }
     }
     return $this;
 }
Пример #8
0
 public function saveProductType(Mage_Core_Model_Abstract $productType, array $data)
 {
     $productTypeData = array('product_type_id' => $data['id'], 'version' => $data['version'], 'name' => $data['name'], 'description' => $data['description'], 'product_class_ids' => $data['productClassIds'], 'locale_code' => $this->getLocaleCode());
     $productType->addData($productTypeData)->save();
     return $this;
 }