本文整理汇总了PHP中Mage_Core_Model_Abstract::getCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Abstract::getCode方法的具体用法?PHP Mage_Core_Model_Abstract::getCode怎么用?PHP Mage_Core_Model_Abstract::getCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Model_Abstract
的用法示例。
在下文中一共展示了Mage_Core_Model_Abstract::getCode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
* Save Object code
*
* @param Mage_Core_Model_Abstract $object
*
* @return $this
*/
public function save(Mage_Core_Model_Abstract $object)
{
$adapter = $this->_getWriteAdapter();
if ($object->getImport() && $object->getCode() && $object->getEntityId()) {
$values = array('import' => $object->getImport(), 'code' => $object->getCode(), 'entity_id' => $object->getEntityId());
$adapter->insertOnDuplicate($this->getMainTable(), $values, array('entity_id'));
} else {
Mage::throwException(Mage::helper('pimgento_core')->__('Error between PIM code and Magento entity'));
}
return $this;
}
示例2: _beforeSave
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
/** @var Mirasvit_Helpdesk_Model_Field $object */
if (!$object->getId()) {
$object->setCreatedAt(Mage::getSingleton('core/date')->gmtDate());
$object->setCode($this->normalize($object->getCode()));
if (in_array($object->getCode(), array('name', 'code', 'external_id', 'user_id', 'description', 'customer_email', 'customer_name', 'order_id', 'last_reply_at'))) {
throw new Exception("Code {$object->getCode()} is not allowed. Please, try different code");
}
}
$object->setUpdatedAt(Mage::getSingleton('core/date')->gmtDate());
return parent::_beforeSave($object);
}
示例3: _beforeSave
/**
* Validate website code before object save
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Core_Model_Resource_Website
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
if (!preg_match('/^[a-z]+[a-z0-9_]*$/', $object->getCode())) {
Mage::throwException(Mage::helper('core')->__('Website code may only contain letters (a-z), numbers (0-9) or underscore(_), the first character must be a letter'));
}
return parent::_beforeSave($object);
}
示例4: _beforeDelete
/**
* Check if group uses as default
*
* @param Mage_Core_Model_Abstract $group
* @throws Mage_Core_Exception
* @return Mage_Core_Model_Resource_Db_Abstract
*/
protected function _beforeDelete(Mage_Core_Model_Abstract $group)
{
if ($group->usesAsDefault()) {
Mage::throwException(Mage::helper('Mage_Customer_Helper_Data')->__('The group "%s" cannot be deleted', $group->getCode()));
}
return parent::_beforeDelete($group);
}
示例5: _beforeSave
/**
* Check store code before save
*
* @param Mage_Core_Model_Abstract $model
* @return Mage_Core_Model_Resource_Store
*/
protected function _beforeSave(Mage_Core_Model_Abstract $model)
{
if (!preg_match('/^[a-z]+[a-z0-9_]*$/', $model->getCode())) {
Mage::throwException(Mage::helper('core')->__('The store code may contain only letters (a-z), numbers (0-9) or underscore(_), the first character must be a letter'));
}
return $this;
}
示例6: _beforeSave
/**
* Apply processing before saving object
*
* @param Mage_Core_Model_Abstract $object
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
if (!$object->getCode()) {
throw new Exception(Mage::helper('ibanners')->__('Banner group must have a unique code'));
}
$object->setCode($this->formatGroupCode($object->getCode()));
if (Mage::getDesign()->getArea() == 'adminhtml') {
foreach ($object->getData() as $field => $value) {
if (preg_match("/^use_config_([a-zA-Z_]{1,})\$/", $field, $result)) {
$object->setData($result[1], null);
$object->unsetData($field);
}
}
}
return parent::_beforeSave($object);
}
示例7: _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);
}