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


PHP AbstractModel::_beforeSave方法代码示例

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


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

示例1: _beforeSave

 /**
  * Processing object before save data
  *
  * @return $this
  */
 protected function _beforeSave()
 {
     if (!$this->getRuleId() && $this->_rule instanceof \Magento\SalesRule\Model\Rule) {
         $this->setRuleId($this->_rule->getId());
     }
     return parent::_beforeSave();
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:12,代码来源:Coupon.php

示例2: _beforeSave

 /**
  * Check order id
  *
  * @return $this
  */
 public function _beforeSave()
 {
     if (null == $this->getOrderId()) {
         throw new \Exception(__('Order id cannot be null'));
     }
     return parent::_beforeSave();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:12,代码来源:Purchased.php

示例3: _beforeSave

 /**
  * @return $this
  */
 protected function _beforeSave()
 {
     parent::_beforeSave();
     if ($this->getAddress()) {
         $this->setAddressId($this->getAddress()->getId());
     }
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:11,代码来源:Rate.php

示例4: _beforeSave

 /**
  * Prevent blocks recursion
  *
  * @return \Magento\Framework\Model\AbstractModel
  * @throws \Magento\Framework\Model\Exception
  */
 protected function _beforeSave()
 {
     $needle = 'block_id="' . $this->getBlockId() . '"';
     if (false == strstr($this->getContent(), $needle)) {
         return parent::_beforeSave();
     }
     throw new \Magento\Framework\Model\Exception(__('Make sure that static block content does not reference the block itself.'));
 }
开发者ID:aiesh,项目名称:magento2,代码行数:14,代码来源:Block.php

示例5: _beforeSave

 /**
  * Before save prepare process
  *
  * @return $this
  */
 protected function _beforeSave()
 {
     parent::_beforeSave();
     /** @var \Magento\Catalog\Model\Product $product */
     $product = $this->productFactory->create();
     $product->load($this->getProductId());
     $typeId = $product->getTypeId() ? $product->getTypeId() : $this->getTypeId();
     $isQty = $this->stockItemService->isQty($typeId);
     if ($isQty) {
         if (!$this->getId()) {
             $this->processIsInStock();
         }
         if ($this->getManageStock() && !$this->verifyStock()) {
             $this->setIsInStock(false)->setStockStatusChangedAutomaticallyFlag(true);
         }
         // if qty is below notify qty, update the low stock date to today date otherwise set null
         $this->setLowStockDate(null);
         if ($this->verifyNotification()) {
             $this->setLowStockDate($this->_localeDate->date(null, null, null, false)->toString(\Magento\Framework\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT));
         }
         $this->setStockStatusChangedAuto(0);
         if ($this->hasStockStatusChangedAutomaticallyFlag()) {
             $this->setStockStatusChangedAuto((int) $this->getStockStatusChangedAutomaticallyFlag());
         }
     } else {
         $this->setQty(0);
     }
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:34,代码来源:Item.php

示例6: _beforeSave

 /**
  * Initialize item identifier before save data
  *
  * @return $this
  */
 protected function _beforeSave()
 {
     if ($this->getItem()) {
         $this->setWishlistItemId($this->getItem()->getId());
     }
     return parent::_beforeSave();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:12,代码来源:Option.php

示例7: _beforeSave

 /**
  * Serelaize old and new data arrays before saving
  *
  * @return $this
  */
 protected function _beforeSave()
 {
     $newData = $this->getNewData(false);
     $this->setNewData(serialize($newData));
     if (!$this->hasCreatedAt()) {
         $this->setCreatedAt($this->dateTime->formatDate(time(), true));
     }
     return parent::_beforeSave();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:14,代码来源:Event.php

示例8: _beforeSave

 /**
  * Stop saving process if file with same report date, account ID and last modified date was already ferched
  *
  * @return \Magento\Framework\Model\AbstractModel
  */
 protected function _beforeSave()
 {
     $this->_dataSaveAllowed = true;
     if ($this->getId()) {
         if ($this->getLastModified() == $this->getReportLastModified()) {
             $this->_dataSaveAllowed = false;
         }
     }
     $this->setLastModified($this->getReportLastModified());
     return parent::_beforeSave();
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:16,代码来源:Settlement.php

示例9: _beforeSave

 /**
  * Validate data before save data
  *
  * @throws \Magento\Framework\Model\Exception
  * @return $this
  */
 protected function _beforeSave()
 {
     if (!$this->getTypeId()) {
         throw new \Magento\Framework\Model\Exception(__('Invalid form type.'));
     }
     if (!$this->getStoreId() && $this->getLabel()) {
         $this->setStoreLabel($this->getStoreId(), $this->getLabel());
     }
     return parent::_beforeSave();
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:16,代码来源:Fieldset.php

示例10: _beforeSave

 /**
  * Verify data required for saving
  *
  * @return $this
  */
 protected function _beforeSave()
 {
     // set parent id
     $this->_verifyPaymentObject();
     if (!$this->getId()) {
         // We need to set order and payment ids only for new transactions
         if (null !== $this->_paymentObject) {
             $this->setPaymentId($this->_paymentObject->getId());
         }
         if (null !== $this->_order) {
             $this->setOrderId($this->_order->getId());
         }
         $this->setCreatedAt($this->_dateFactory->create()->gmtDate());
     }
     return parent::_beforeSave();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:21,代码来源:Transaction.php

示例11: _beforeSave

 /**
  * Processing object before save data
  *
  * @return $this
  */
 protected function _beforeSave()
 {
     if ($this->getContentHeight() == 0) {
         $this->setContentHeight('');
         //converting zero Content-Height
     }
     if ($this->getContentHeight() && !preg_match('/(' . implode("|", $this->allowedCssUnits) . ')/', $this->getContentHeight())) {
         $contentHeight = $this->getContentHeight() . 'px';
         //setting default units for Content-Height
         $this->setContentHeight($contentHeight);
     }
     return parent::_beforeSave();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:18,代码来源:Agreement.php

示例12: _beforeSave

 /**
  * Before Event save process
  *
  * @return $this
  */
 protected function _beforeSave()
 {
     $date = $this->_dateFactory->create();
     $this->setLoggedAt($date->gmtDate());
     return parent::_beforeSave();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:11,代码来源:Event.php

示例13: _beforeSave

 /**
  * Before save unlock attributes
  *
  * @return \Magento\Catalog\Model\AbstractModel
  */
 protected function _beforeSave()
 {
     $this->unlockAttributes();
     return parent::_beforeSave();
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:10,代码来源:AbstractModel.php

示例14: _beforeSave

 /**
  * Prepare customer/visitor, store data before save
  *
  * @return $this
  */
 protected function _beforeSave()
 {
     parent::_beforeSave();
     if (!$this->hasVisitorId()) {
         $this->setVisitorId($this->getVisitorId());
     }
     if (!$this->hasCustomerId()) {
         $this->setCustomerId($this->getCustomerId());
     }
     if (!$this->hasStoreId()) {
         $this->setStoreId($this->getStoreId());
     }
     if (!$this->hasAddedAt()) {
         $this->setAddedAt($this->dateTime->now());
     }
     return $this;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:22,代码来源:AbstractIndex.php

示例15: _beforeSave

 /**
  * Prepare data before save
  *
  * @return $this
  */
 protected function _beforeSave()
 {
     $this->_prepareData();
     return parent::_beforeSave();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:10,代码来源:Group.php


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