當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。