protected function _afterSave(Mage_Core_Model_Abstract $object) { $descriptionTable = $this->getTable('customoptiondescription/product_option_description'); if (!$object->getData('scope', 'description')) { $statement = $this->_getReadAdapter()->select()->from($descriptionTable)->where('option_id = ' . $object->getId() . ' and store_id = ?', 0); if ($this->_getReadAdapter()->fetchOne($statement)) { if ($object->getStoreId() == '0') { $this->_getWriteAdapter()->update($descriptionTable, array('description' => $object->getDescription()), $this->_getWriteAdapter()->quoteInto('option_id=' . $object->getId() . ' AND store_id=?', 0)); } } else { $this->_getWriteAdapter()->insert($descriptionTable, array('option_id' => $object->getId(), 'store_id' => 0, 'description' => $object->getDescription())); } } if ($object->getStoreId() != '0' && !$object->getData('scope', 'description')) { $statement = $this->_getReadAdapter()->select()->from($descriptionTable)->where('option_id = ' . $object->getId() . ' and store_id = ?', $object->getStoreId()); if ($this->_getReadAdapter()->fetchOne($statement)) { $this->_getWriteAdapter()->update($descriptionTable, array('description' => $object->getDescription()), $this->_getWriteAdapter()->quoteInto('option_id=' . $object->getId() . ' AND store_id=?', $object->getStoreId())); } else { $this->_getWriteAdapter()->insert($descriptionTable, array('option_id' => $object->getId(), 'store_id' => $object->getStoreId(), 'description' => $object->getDescription())); } } elseif ($object->getData('scope', 'description')) { $this->_getWriteAdapter()->delete($descriptionTable, $this->_getWriteAdapter()->quoteInto('option_id = ' . $object->getId() . ' AND store_id = ?', $object->getStoreId())); } return parent::_afterSave($object); }
protected function _afterSave(Mage_Core_Model_Abstract $object) { $storeId = Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID; if ($object->getStoreId() != $storeId) { $storeId = $object->getStoreId(); } // save view_mode $table = $this->getTable('mageworx_customoptions/option_view_mode'); if (!$object->getData('scope', 'view_mode') && !is_null($object->getViewMode())) { $select = $this->_getReadAdapter()->select()->from($table)->where('option_id = ?', $object->getId())->where('store_id = ?', $storeId); if ($this->_getReadAdapter()->fetchOne($select)) { $this->_getWriteAdapter()->update($table, array('view_mode' => $object->getViewMode()), 'option_id = ' . $object->getId() . ' AND store_id = ' . $storeId); } else { $this->_getWriteAdapter()->insert($table, array('option_id' => $object->getId(), 'store_id' => $storeId, 'view_mode' => $object->getViewMode())); } } elseif ($object->getData('scope', 'view_mode') || is_null($object->getViewMode())) { $this->_getWriteAdapter()->delete($table, 'option_id = ' . $object->getId() . ' AND store_id = ' . $storeId); } // save description $table = $this->getTable('mageworx_customoptions/option_description'); if (!$object->getData('scope', 'description') && $object->getDescription()) { $select = $this->_getReadAdapter()->select()->from($table)->where('option_id = ?', $object->getId())->where('store_id = ?', $storeId); if ($this->_getReadAdapter()->fetchOne($select)) { $this->_getWriteAdapter()->update($table, array('description' => $object->getDescription()), 'option_id = ' . $object->getId() . ' AND store_id = ' . $storeId); } else { $this->_getWriteAdapter()->insert($table, array('option_id' => $object->getId(), 'store_id' => $storeId, 'description' => $object->getDescription())); } } elseif ($object->getData('scope', 'description') || !$object->getDescription()) { $this->_getWriteAdapter()->delete($table, 'option_id = ' . $object->getId() . ' AND store_id = ' . $storeId); } // save default text $table = $this->getTable('mageworx_customoptions/option_default'); if (!$object->getData('scope', 'default_text') && $object->getDefaultText()) { $select = $this->_getReadAdapter()->select()->from($table)->where('option_id = ?', $object->getId())->where('store_id = ?', $storeId); if ($this->_getReadAdapter()->fetchOne($select)) { $this->_getWriteAdapter()->update($table, array('default_text' => $object->getDefaultText()), 'option_id = ' . $object->getId() . ' AND store_id = ' . $storeId); } else { $this->_getWriteAdapter()->insert($table, array('option_id' => $object->getId(), 'store_id' => $storeId, 'default_text' => $object->getDefaultText())); } } elseif ($object->getData('scope', 'default_text') || !$object->getDefaultText()) { $this->_getWriteAdapter()->delete($table, 'option_id = ' . $object->getId() . ' AND store_id = ' . $storeId); } return parent::_afterSave($object); }
public function deletePrices($option_id) { $condition = $this->_getWriteAdapter()->quoteInto('option_id=?', $option_id); $this->_getWriteAdapter()->delete($this->getTable('catalog/product_option_aitimage'), $condition); return parent::deletePrices($option_id); }
protected function _afterSave(Mage_Core_Model_Abstract $object) { $this->_saveDescription($object); $this->_saveBlockTitle($object); return parent::_afterSave($object); }