当前位置: 首页>>代码示例>>PHP>>正文


PHP AbstractModel::getCode方法代码示例

本文整理汇总了PHP中Magento\Framework\Model\AbstractModel::getCode方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractModel::getCode方法的具体用法?PHP AbstractModel::getCode怎么用?PHP AbstractModel::getCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\Model\AbstractModel的用法示例。


在下文中一共展示了AbstractModel::getCode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _beforeSave

 /**
  * Validate website code before object save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if (!preg_match('/^[a-z]+[a-z0-9_]*$/', $object->getCode())) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Website code may only contain letters (a-z), numbers (0-9) or underscore (_),' . ' and the first character must be a letter.'));
     }
     return parent::_beforeSave($object);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:14,代码来源:Website.php

示例2: _beforeDelete

 /**
  * Check if group uses as default
  *
  * @param  \Magento\Framework\Model\AbstractModel $group
  * @return $this
  * @throws \Magento\Framework\Model\Exception
  */
 protected function _beforeDelete(\Magento\Framework\Model\AbstractModel $group)
 {
     if ($group->usesAsDefault()) {
         throw new \Magento\Framework\Model\Exception(__('The group "%1" cannot be deleted', $group->getCode()));
     }
     return parent::_beforeDelete($group);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:14,代码来源:Group.php

示例3: _beforeSave

 /**
  * Process post data before saving
  *
  * @param \Smart2Pay\GlobalPay\Model\Country $object
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if (!$object->getCode()) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Please provide country code.'));
     }
     if (!$object->getName()) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Please provide country name.'));
     }
     if ($this->checkCode($object)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Country code already exists in database.'));
     }
     return parent::_beforeSave($object);
 }
开发者ID:smart2pay,项目名称:magento20,代码行数:20,代码来源:Country.php

示例4: _beforeSave

 /**
  * {@inheritdoc}
  */
 protected function _beforeSave(AbstractModel $object)
 {
     $reindexRequired = false;
     if ($object->hasData('attributes') && is_array($object->getData('attributes'))) {
         $serialized = serialize($object->getData('attributes'));
         if ($object->getData('attributes_serialized') != $serialized) {
             $reindexRequired = true;
         }
         $object->setData('attributes_serialized', $serialized);
     }
     if ($object->hasData('properties') && is_array($object->getData('properties'))) {
         $serialized = serialize($object->getData('properties'));
         if ($object->getData('properties_serialized') != $serialized) {
             $reindexRequired = true;
         }
         $object->setData('properties_serialized', $serialized);
     }
     if ($reindexRequired && !$object->dataHasChangedFor('status')) {
         $object->setStatus(Config::INDEX_STATUS_INVALID);
     }
     $object->setCode($object->getCode());
     return $this;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:26,代码来源:Index.php

示例5: _beforeSave

 /**
  * Prepare data before save
  *
  * @param \Magento\Framework\Model\AbstractModel $group
  * @return $this
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $group)
 {
     /** @var \Magento\Customer\Model\Group $group */
     $group->setCode(substr($group->getCode(), 0, $group::GROUP_CODE_MAX_LENGTH));
     return parent::_beforeSave($group);
 }
开发者ID:nja78,项目名称:magento2,代码行数:12,代码来源:Group.php


注:本文中的Magento\Framework\Model\AbstractModel::getCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。