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


PHP AbstractModel::hasData方法代码示例

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


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

示例1: _beforeSave

 /**
  * Perform actions before object save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     $belongsToQuoteItem = $object->hasData(CommentInterface::QUOTE_ITEM_ID_COLUMN);
     $belongsToOrderItem = $object->hasData(CommentInterface::ORDER_ITEM_ID_COLUMN);
     $hasText = $object->hasData(CommentInterface::TEXT_COLUMN);
     // A comment should either be attached to a quote item or order item...
     if (!$belongsToQuoteItem || !$belongsToOrderItem) {
         throw new \Magento\Framework\Exception\LocalizedException(__('A comment should belong to either a quote item or order item.'));
     }
     // ...but not to both
     if ($belongsToQuoteItem && $belongsToOrderItem) {
         throw new \Magento\Framework\Exception\LocalizedException(__('A comment cannot belong to both a quote item and order item.'));
     }
     if (!$hasText) {
         throw new \Magento\Framework\Exception\LocalizedException(__('A comment requirescomp text.'));
     }
     return parent::_beforeSave($object);
 }
开发者ID:magento-hackathon,项目名称:Hackathon_OrderItemComments,代码行数:24,代码来源:Comment.php

示例2: validate

 /**
  * Validate product attribute value for condition
  *
  * @param \Magento\Framework\Model\AbstractModel $model
  * @return bool
  */
 public function validate(\Magento\Framework\Model\AbstractModel $model)
 {
     $attrCode = $this->getAttribute();
     if ('category_ids' == $attrCode) {
         return $this->validateAttribute($model->getAvailableInCategories());
     }
     $oldAttrValue = $model->hasData($attrCode) ? $model->getData($attrCode) : null;
     $this->_setAttributeValue($model);
     $result = $this->validateAttribute($model->getData($this->getAttribute()));
     $this->_restoreOldAttrValue($model, $oldAttrValue);
     return (bool) $result;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:18,代码来源:Product.php

示例3: _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

示例4: _beforeSave

 /**
  * Perform actions before object save
  *
  * @param AbstractModel $object
  * @return $this
  */
 protected function _beforeSave(AbstractModel $object)
 {
     if (!$object->getId()) {
         $object->setCreatedAt($this->_date->gmtDate());
     }
     if ($object->hasData('stores') && is_array($object->getStores())) {
         $stores = $object->getStores();
         $stores[] = 0;
         $object->setStores($stores);
     } elseif ($object->hasData('stores')) {
         $object->setStores([$object->getStores(), 0]);
     }
     return $this;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:20,代码来源:Review.php

示例5: validate

 /**
  * @param \Magento\Framework\Model\AbstractModel $model
  * @return bool
  */
 public function validate(\Magento\Framework\Model\AbstractModel $model)
 {
     if (!$model->hasData($this->getAttribute())) {
         $model->load($model->getId());
     }
     $attributeValue = $model->getData($this->getAttribute());
     return $this->validateAttribute($attributeValue);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:12,代码来源:AbstractCondition.php


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