/** * Perform actions after object save * * @param Mage_Core_Model_Abstract $object * @return Xcom_Mapping_Model_Resource_Attribute */ protected function _afterSave(Mage_Core_Model_Abstract $object) { parent::_afterSave($object); $channelDecoration = $object->getChannelDecoration(); if ($channelDecoration) { $data = array(); foreach ($channelDecoration as $channel) { $data[] = array_merge($channel, array($this->getIdFieldName() => $object->getId())); } $adapter = $this->_getWriteAdapter(); $adapter->insertOnDuplicate($this->getTable('xcom_mapping/attribute_channel'), $data, array('is_required', 'is_variation')); } return $this; }
/** * Perform actions after object save * * @param Mage_Core_Model_Abstract $object * @return Xcom_Mapping_Model_Resource_Product_Type */ protected function _afterSave(Mage_Core_Model_Abstract $object) { parent::_afterSave($object); $productClasses = $object->getProductClassIds(); if (!empty($productClasses)) { $productClassesMappingIds = $this->_getMappingClassIdsByClassIds($productClasses); if (!empty($productClassesMappingIds)) { $data = array(); foreach ($productClassesMappingIds as $productClassId) { $data[] = array_merge($productClassId, array('mapping_product_type_id' => $object->getId())); } $this->_getWriteAdapter()->delete($this->getTable('xcom_mapping/product_class_type'), array($this->_getWriteAdapter()->quoteInto('mapping_product_type_id = ?', $object->getId()))); $this->_getWriteAdapter()->insertOnDuplicate($this->getTable('xcom_mapping/product_class_type'), $data, array('mapping_product_class_id', 'mapping_product_type_id')); } } return $this; }
/** * @param Mage_Core_Model_Abstract $object * @return Mage_Core_Model_Mysql4_Abstract */ protected function _afterLoad(Mage_Core_Model_Abstract $object) { $channelCodes = $object->getChannelCodes(); if (false !== strpos($channelCodes, ',')) { $object->setChannelCodes(explode(',', $channelCodes)); } return parent::_beforeSave($object); }