本文整理汇总了PHP中Mage_Core_Model_Abstract::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Abstract::getId方法的具体用法?PHP Mage_Core_Model_Abstract::getId怎么用?PHP Mage_Core_Model_Abstract::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Model_Abstract
的用法示例。
在下文中一共展示了Mage_Core_Model_Abstract::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _beforeSave
/**
* Action before save
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Api_Model_Resource_Acl_Role
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
if (!$object->getId()) {
$this->setCreated(Mage::getSingleton('core/date')->gmtDate());
}
return $this;
}
示例2: _afterSave
/**
* Process page data before saving
*
* @param Mage_Core_Model_Abstract $object
*/
protected function _afterSave(Mage_Core_Model_Abstract $object)
{
$condition = $this->_getWriteAdapter()->quoteInto('productattachments_id = ?', $object->getId());
$r = $this->_getReadAdapter()->select('p.block_name_product')->from(array('p' => $this->getTable('productattachments_store')))->where('productattachments_id = (?)', $object->getId())->limit(1);
$row = $this->_getReadAdapter()->fetchRow($r);
$block_name = '';
if (isset($row['block_name_product'])) {
$block_name = $row['block_name_product'];
}
$this->_getWriteAdapter()->delete($this->getTable('productattachments_store'), $condition);
foreach ((array) $object->getData('stores') as $store) {
$storeArray = array();
$storeArray['productattachments_id'] = $object->getId();
$storeArray['store_id'] = $store;
$this->_getWriteAdapter()->insert($this->getTable('productattachments_store'), $storeArray);
}
//Get Related Products
$links = $object['links'];
if (isset($links['related'])) {
$productIds = Mage::helper('adminhtml/js')->decodeGridSerializedInput($links['related']);
$this->_getWriteAdapter()->delete($this->getTable('productattachments_products'), $condition);
//Save Related Products
foreach ($productIds as $_product) {
$newsArray = array();
$newsArray['productattachments_id'] = $object->getId();
$newsArray['product_id'] = $_product;
$newsArray['block_name_product'] = $block_name;
$this->_getWriteAdapter()->insert($this->getTable('productattachments_products'), $newsArray);
}
}
return parent::_afterSave($object);
}
示例3: _afterSave
protected function _afterSave(Mage_Core_Model_Abstract $object)
{
$read = $this->_getReadAdapter();
$write = $this->_getWriteAdapter();
if ($object->getType() == BL_CustomGrid_Model_Options_Source::SOURCE_TYPE_MAGE_MODEL) {
// Save corresponding model
$table = $this->getTable('customgrid/options_source_model');
// Delete source model(s)
$delete = array($write->quoteInto('source_id = ?', $object->getId()));
if ($object->getModelId()) {
// But keep updated model if set
$delete[] = $write->quoteInto('model_id != ?', $object->getModelId());
}
$write->delete($table, $delete);
// Insert or update model
$values = array('source_id' => $object->getId(), 'model_name' => $object->getModelName(), 'model_type' => $object->getModelType(), 'method' => $object->getMethod(), 'return_type' => $object->getReturnType(), 'value_key' => $object->getValueKey(), 'label_key' => $object->getLabelKey());
$updated = false;
if ($object->getModelId()) {
$query = $read->select()->from($table)->where('source_id = ' . $object->getId() . ' AND model_id = ?', $object->getModelId());
if ($read->fetchOne($query)) {
// Update model if given ID correspond to a model that actually belong to saved source
$write->update($table, $values, $write->quoteInto('model_id = ?', $object->getModelId()));
$updated = true;
}
}
if (!$updated) {
// Else (no ID or not found for source), insert it
$write->insert($table, $values);
}
} else {
// Save corresponding options
$table = $this->getTable('customgrid/options_source_option');
$options = $object->getOptions();
if (is_array($options)) {
// Get existing options IDs
$select = $read->select()->from($table, 'option_id')->where('source_id = ?', $object->getId());
$existingIds = $read->fetchCol($select);
$foundIds = array();
foreach ($options as $option) {
$values = array('source_id' => $object->getId(), 'value' => $option['value'], 'label' => $option['label']);
if ($option['option_id'] > 0 && in_array($option['option_id'], $existingIds) && (!isset($option['delete']) || !$option['delete'])) {
// Existing option to update
$write->update($table, $values, $write->quoteInto('option_id = ?', $option['option_id']));
$foundIds[] = $option['option_id'];
} elseif (!isset($option['delete']) || !$option['delete']) {
// New (or not found for saved source) option to insert
$write->insert($table, $values);
}
}
// Remove missing / deleted options
$delete = array_diff($existingIds, $foundIds);
if (!empty($delete)) {
foreach ($delete as $optionId) {
$write->delete($table, $write->quoteInto('option_id = ?', $optionId));
}
}
}
}
return parent::_afterSave($object);
}
示例4: _afterLoad
/**
*
* @param Mage_Core_Model_Abstract $object
*/
protected function _afterLoad(Mage_Core_Model_Abstract $object)
{
if ($object->getId()) {
// Stores
$select = $this->_getReadAdapter()->select()->from($this->getTable('auguria_sliders/stores'))->where('slider_id = ?', $object->getId());
if ($data = $this->_getReadAdapter()->fetchAll($select)) {
$storesArray = array();
foreach ($data as $row) {
$storesArray[] = $row['store_id'];
}
$object->setData('stores', $storesArray);
}
// Cms pages
$select = $this->_getReadAdapter()->select()->from($this->getTable('auguria_sliders/pages'))->where('slider_id = ?', $object->getId());
if ($data = $this->_getReadAdapter()->fetchAll($select)) {
$pagesArray = array();
foreach ($data as $row) {
$pagesArray[] = $row['page_id'];
}
$object->setData('pages', $pagesArray);
}
// Category ids
$select = $this->_getReadAdapter()->select()->from($this->getTable('auguria_sliders/categories'))->where('slider_id = ?', $object->getId());
if ($data = $this->_getReadAdapter()->fetchAll($select)) {
$categoriesArray = array();
foreach ($data as $row) {
$categoriesArray[] = $row['category_id'];
}
$object->setData('category_ids', $categoriesArray);
}
}
return parent::_afterLoad($object);
}
示例5: tearDown
/**
* Reset current store to admin and clean up created customer entity
*/
protected function tearDown()
{
$this->setCurrentStore('admin');
if ($this->_model && $this->_model->getId()) {
$this->_model->delete();
}
}
示例6: _afterSave
/**
* Perform actions after object save
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Eav_Model_Resource_Entity_Attribute_Set
*/
protected function _afterSave(Mage_Core_Model_Abstract $object)
{
if ($object->getGroups()) {
/* @var $group Mage_Eav_Model_Entity_Attribute_Group */
foreach ($object->getGroups() as $group) {
$group->setAttributeSetId($object->getId());
if ($group->itemExists() && !$group->getId()) {
continue;
}
$group->save();
}
}
if ($object->getRemoveGroups()) {
foreach ($object->getRemoveGroups() as $group) {
/* @var $group Mage_Eav_Model_Entity_Attribute_Group */
$group->delete();
}
Mage::getResourceModel('eav/entity_attribute_group')->updateDefaultGroup($object->getId());
}
if ($object->getRemoveAttributes()) {
foreach ($object->getRemoveAttributes() as $attribute) {
/* @var $attribute Mage_Eav_Model_Entity_Attribute */
$attribute->deleteEntity();
}
}
return parent::_afterSave($object);
}
示例7: _afterLoad
/**
* Set personalisation tags on the object.
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Cms_Model_Resource_Block
*/
protected function _afterLoad(Mage_Core_Model_Abstract $object)
{
if ($object->getId()) {
$object->setData('personalisation_tags', $this->lookupPersonalisationTags($object->getId()));
}
return parent::_afterLoad($object);
}
示例8: _afterSave
/**
* Bind gift rule to customer group(s) and website(s).
* Save rule's associated store labels.
* Save product attributes used in rule.
*
* @param Mage_Core_Model_Abstract $object
*
* @return Mage_SalesRule_Model_Resource_Rule
*/
protected function _afterSave(Mage_Core_Model_Abstract $object)
{
if ($object->hasStoreLabels()) {
$this->saveStoreLabels($object->getId(), $object->getStoreLabels());
}
if ($object->hasWebsiteIds()) {
$websiteIds = $object->getWebsiteIds();
if (!is_array($websiteIds)) {
$websiteIds = explode(',', (string) $websiteIds);
}
$this->bindRuleToEntity($object->getId(), $websiteIds, 'website');
}
if ($object->hasCustomerGroupIds()) {
$customerGroupIds = $object->getCustomerGroupIds();
if (!is_array($customerGroupIds)) {
$customerGroupIds = explode(',', (string) $customerGroupIds);
}
$this->bindRuleToEntity($object->getId(), $customerGroupIds, 'customer_group');
}
if ($object->hasProductIds()) {
$productIds = $object->getProductIds();
if (!is_array($productIds)) {
$productIds = explode(',', (string) $productIds);
}
$this->bindRuleToEntity($object->getId(), $productIds, 'product');
}
// Save product attributes used in rule
$ruleProductAttributes = array_merge($this->getProductAttributes(serialize($object->getConditions()->asArray())), $this->getProductAttributes(serialize($object->getActions()->asArray())));
if (count($ruleProductAttributes)) {
$this->setActualProductAttributes($object, $ruleProductAttributes);
}
return parent::_afterSave($object);
}
示例9: _saveOption
/**
* Save attribute options
* Override to save image to attribute option
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Eav_Model_Resource_Entity_Attribute
* @version 1.7.0.2
*/
protected function _saveOption(Mage_Core_Model_Abstract $object)
{
$option = $object->getOption();
if (is_array($option)) {
$adapter = $this->_getWriteAdapter();
$optionTable = $this->getTable('eav/attribute_option');
$optionValueTable = $this->getTable('eav/attribute_option_value');
$stores = Mage::app()->getStores(true);
if (isset($option['value'])) {
$attributeDefaultValue = array();
if (!is_array($object->getDefault())) {
$object->setDefault(array());
}
foreach ($option['value'] as $optionId => $values) {
$intOptionId = (int) $optionId;
if (!empty($option['delete'][$optionId])) {
if ($intOptionId) {
$adapter->delete($optionTable, array('option_id = ?' => $intOptionId));
}
continue;
}
$sortOrder = !empty($option['order'][$optionId]) ? $option['order'][$optionId] : 0;
$image = !empty($option['image'][$optionId]) ? $option['image'][$optionId] : null;
$thumb = !empty($option['thumb'][$optionId]) ? $option['thumb'][$optionId] : null;
if (!$intOptionId) {
$data = array('attribute_id' => $object->getId(), 'sort_order' => $sortOrder, 'image' => $image, 'thumb' => $thumb);
$adapter->insert($optionTable, $data);
$intOptionId = $adapter->lastInsertId($optionTable);
} else {
$data = array('sort_order' => $sortOrder, 'image' => $image, 'thumb' => $thumb);
$where = array('option_id =?' => $intOptionId);
$adapter->update($optionTable, $data, $where);
}
if (in_array($optionId, $object->getDefault())) {
if ($object->getFrontendInput() == 'multiselect') {
$attributeDefaultValue[] = $intOptionId;
} elseif ($object->getFrontendInput() == 'select') {
$attributeDefaultValue = array($intOptionId);
}
}
// Default value
if (!isset($values[0])) {
Mage::throwException(Mage::helper('eav')->__('Default option value is not defined'));
}
$adapter->delete($optionValueTable, array('option_id =?' => $intOptionId));
foreach ($stores as $store) {
if (isset($values[$store->getId()]) && (!empty($values[$store->getId()]) || $values[$store->getId()] == "0")) {
$data = array('option_id' => $intOptionId, 'store_id' => $store->getId(), 'value' => $values[$store->getId()]);
$adapter->insert($optionValueTable, $data);
}
}
}
$bind = array('default_value' => implode(',', $attributeDefaultValue));
$where = array('attribute_id =?' => $object->getId());
$adapter->update($this->getMainTable(), $bind, $where);
}
}
return $this;
}
示例10: saveModelAndFailOnUpdate
/**
* Callback for save method in mocked model
*
* @throws Magento_Exception
*/
public function saveModelAndFailOnUpdate()
{
if (!$this->_model->getId()) {
$this->saveModelSuccessfully();
} else {
throw new Magento_Exception('Synthetic model update failure.');
}
}
示例11: _afterDelete
protected function _afterDelete(Mage_Core_Model_Abstract $object)
{
//delete values
$this->_getReadAdapter()->delete($this->getTable('webforms/results_values'), 'field_id =' . $object->getId());
$this->_getReadAdapter()->delete($this->getTable('webforms/logic'), 'field_id =' . $object->getId());
Mage::dispatchEvent('webforms_field_delete', array('field' => $object));
return parent::_afterDelete($object);
}
示例12: _afterLoad
/**
* Perform operations after object load
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Cms_Model_Resource_Page
*/
protected function _afterLoad(Mage_Core_Model_Abstract $object)
{
if ($object->getId()) {
$products = $this->getProductIds($object->getId());
$object->setData('product_id', $products);
}
return parent::_afterLoad($object);
}
示例13: _afterLoad
protected function _afterLoad(Mage_Core_Model_Abstract $object)
{
if ($object->getId()) {
$stores = $this->listStoreIds($object->getId());
$object->setData('store_id', $stores);
}
return parent::_afterLoad($object);
}
开发者ID:ankita-parashar,项目名称:magento,代码行数:8,代码来源:Magebuzz_Multipleorderemail_Model_Mysql4_Multipleorderemailrule.php
示例14: _afterDelete
protected function _afterDelete(Mage_Core_Model_Abstract $object)
{
//delete values
$values = $this->_getReadAdapter()->delete($this->getTable('webforms/results_values'), 'result_id = ' . $object->getId());
$dir = Mage::getBaseDir('media') . DS . 'webforms' . DS . $object->getId();
$this->rrmdir($dir);
Mage::dispatchEvent('webforms_result_delete', array('result' => $object));
return parent::_afterDelete($object);
}
示例15: _afterSave
/**
* Processing object after save data
* Update app_code as Store + Device + 123 (increment).
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Core_Model_Abstract
*/
protected function _afterSave(Mage_Core_Model_Abstract $object)
{
$appCode = $object->getCode();
$isCodePrefixed = $object->isCodePrefixed();
if (!$isCodePrefixed) {
$this->_getWriteAdapter()->update($this->getMainTable(), array('code' => $appCode . $object->getId()), $this->_getWriteAdapter()->quoteInto($this->getIdFieldName() . '=?', $object->getId()));
}
return parent::_afterSave($object);
}