本文整理汇总了PHP中Mage_Core_Model_Abstract::setId方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Abstract::setId方法的具体用法?PHP Mage_Core_Model_Abstract::setId怎么用?PHP Mage_Core_Model_Abstract::setId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Model_Abstract
的用法示例。
在下文中一共展示了Mage_Core_Model_Abstract::setId方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _beforeSave
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
$connection = $this->_getWriteAdapter();
$select = $connection->select()->from($this->getMainTable(), 'key_id')->where('string=?', $object->getString())->where('store_id=?', 0);
$object->setId($connection->fetchOne($select));
return parent::_beforeSave($object);
}
示例2: _checkUnique
/**
* Validate unique configuration data before save
* Set id to object if exists configuration instead of throw exception
*
* @param Mage_Core_Model_Config_Data $object
* @return Mage_Core_Model_Resource_Config_Data
*/
protected function _checkUnique(Mage_Core_Model_Abstract $object)
{
$select = $this->_getReadAdapter()->select()->from($this->getMainTable(), array($this->getIdFieldName()))->where('scope = :scope')->where('scope_id = :scope_id')->where('path = :path');
$bind = array('scope' => $object->getScope(), 'scope_id' => $object->getScopeId(), 'path' => $object->getPath());
$configId = $this->_getReadAdapter()->fetchOne($select, $bind);
if ($configId) {
$object->setId($configId);
}
return $this;
}
示例3: insertJoinedDatabase
public function insertJoinedDatabase(Mage_Core_Model_Abstract $object)
{
$adapter = $this->_getWriteAdapter();
$select = $adapter->select()->from($this->getMainTable(), array($this->getIdFieldName()))->where('program_id = ?', $object->getData('program_id'))->where('account_id = ?', $object->getData('account_id'));
if ($adapter->fetchOne($select) === false) {
$object->setId(null);
$this->save($object);
}
return $this;
}
示例4: _cleanProductsCache
/**
* Clean cache by specified product and its ids
*
* @param Mage_Core_Model_Abstract $entity
* @param array $ids
*/
protected function _cleanProductsCache(Mage_Core_Model_Abstract $entity, array $ids)
{
$cacheTags = array();
foreach ($ids as $entityId) {
$entity->setId($entityId);
$cacheTags = array_unique(array_merge($cacheTags, $entity->getCacheIdTagsWithCategories()));
}
if (!empty($cacheTags)) {
Enterprise_PageCache_Model_Cache::getCacheInstance()->clean($cacheTags);
}
}
示例5: _cleanEntityCache
/**
* Clean cache by specified entity and its ids
*
* @param Mage_Core_Model_Abstract $entity
* @param array $ids
*/
protected function _cleanEntityCache(Mage_Core_Model_Abstract $entity, array $ids)
{
$cacheTags = array();
foreach ($ids as $entityId) {
$entity->setId($entityId);
$cacheTags = array_merge($cacheTags, $entity->getCacheIdTags());
}
if (!empty($cacheTags)) {
Ves_Optimize_Model_Cache::getCacheInstance()->clean($cacheTags);
}
}
示例6: _beforeSave
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
if (!$object->getId() && $object->getStatus() == $object->getApprovedStatus()) {
$searchTag = new Varien_Object();
$this->loadByName($searchTag, $object->getName());
if ($searchTag->getData($this->getIdFieldName()) && $searchTag->getStatus() == $object->getPendingStatus()) {
$object->setId($searchTag->getData($this->getIdFieldName()));
}
}
if (Mage::helper('core/string')->strlen($object->getName()) > 255) {
$object->setName(Mage::helper('core/string')->substr($object->getName(), 0, 255));
}
return parent::_beforeSave($object);
}
示例7: save
public function save(Mage_Core_Model_Abstract $object)
{
$write = $this->_getWriteAdapter();
$setId = $object->getId();
$data = array('attribute_set_name' => $object->getAttributeSetName());
$write->beginTransaction();
try {
if (intval($setId) > 0) {
$condition = $write->quoteInto("{$this->getMainTable()}.{$this->getIdFieldName()} = ?", $setId);
$write->update($this->getMainTable(), $data, $condition);
if ($object->getGroups()) {
foreach ($object->getGroups() as $group) {
$group->save();
}
}
if ($object->getRemoveGroups()) {
foreach ($object->getRemoveGroups() as $group) {
$group->delete($group->getId());
}
}
if ($object->getRemoveAttributes()) {
foreach ($object->getRemoveAttributes() as $attribute) {
$attribute->deleteEntity();
}
}
} else {
$data['entity_type_id'] = $object->getEntityTypeId();
$write->insert($this->getMainTable(), $data);
$object->setId($write->lastInsertId());
}
$write->commit();
} catch (Exception $e) {
$write->rollback();
throw new Exception($e->getMessage());
}
}
示例8: _beforeSave
/**
* Before save
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Core_Model_Resource_Translate_String
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
$adapter = $this->_getWriteAdapter();
$select = $adapter->select()->from($this->getMainTable(), 'key_id')->where('string = :string')->where('store_id = :store_id');
$bind = array('string' => $object->getString(), 'store_id' => Mage_Core_Model_App::ADMIN_STORE_ID);
$object->setId($adapter->fetchOne($select, $bind));
return parent::_beforeSave($object);
}
示例9: clearEntityCache
/**
* clearEntityCache
*
* @param Mage_Core_Model_Abstract $entity
* @param array $ids
* @return void
*/
public function clearEntityCache(Mage_Core_Model_Abstract $entity, array $ids)
{
$cacheTags = array();
foreach ($ids as $entityId) {
$entity->setId($entityId);
$cacheTags = array_merge($cacheTags, $entity->getCacheIdTags());
}
if (!empty($cacheTags)) {
Enterprise_PageCache_Model_Cache::getCacheInstance()->clean($cacheTags);
}
}
示例10: deleteModelSuccessfully
/**
* Callback for delete method in mocked model
*/
public function deleteModelSuccessfully()
{
$this->_model->setId(null);
}