當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AbstractModel::_beforeSave方法代碼示例

本文整理匯總了PHP中Magento\Sales\Model\AbstractModel::_beforeSave方法的典型用法代碼示例。如果您正苦於以下問題:PHP AbstractModel::_beforeSave方法的具體用法?PHP AbstractModel::_beforeSave怎麽用?PHP AbstractModel::_beforeSave使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Sales\Model\AbstractModel的用法示例。


在下文中一共展示了AbstractModel::_beforeSave方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _beforeSave

 /**
  * Before object save manipulations
  *
  * @return $this
  */
 protected function _beforeSave()
 {
     return parent::_beforeSave();
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:9,代碼來源:Invoice.php

示例2: _beforeSave

 /**
  * Before object save manipulations
  *
  * @return $this
  */
 protected function _beforeSave()
 {
     parent::_beforeSave();
     if (!$this->getOrderId() && $this->getOrder()) {
         $this->setOrderId($this->getOrder()->getId());
         $this->setBillingAddressId($this->getOrder()->getBillingAddress()->getId());
     }
     return $this;
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:14,代碼來源:Creditmemo.php

示例3: _beforeSave

 /**
  * Processing object before save data
  *
  * @return $this
  */
 protected function _beforeSave()
 {
     parent::_beforeSave();
     $this->_checkState();
     if (!$this->getId()) {
         $store = $this->getStore();
         $name = array($store->getWebsite()->getName(), $store->getGroup()->getName(), $store->getName());
         $this->setStoreName(implode("\n", $name));
     }
     if (!$this->getIncrementId()) {
         $incrementId = $this->_eavConfig->getEntityType('order')->fetchNewIncrementId($this->getStoreId());
         $this->setIncrementId($incrementId);
     }
     /**
      * Process items dependency for new order
      */
     if (!$this->getId()) {
         $itemsCount = 0;
         foreach ($this->getAllItems() as $item) {
             $parent = $item->getQuoteParentItemId();
             if ($parent && !$item->getParentItem()) {
                 $item->setParentItem($this->getItemByQuoteItemId($parent));
             } elseif (!$parent) {
                 $itemsCount++;
             }
         }
         // Set items count
         $this->setTotalItemCount($itemsCount);
     }
     /** TODO refactor getCustomer usage after MAGETWO-20182 and MAGETWO-20258 are done */
     $isNewCustomer = !$this->getCustomerId() || $this->getCustomerId() === true;
     if ($isNewCustomer && $this->getCustomer()) {
         $this->setCustomerId($this->getCustomer()->getId());
     }
     if ($this->hasBillingAddressId() && $this->getBillingAddressId() === null) {
         $this->unsBillingAddressId();
     }
     if ($this->hasShippingAddressId() && $this->getShippingAddressId() === null) {
         $this->unsShippingAddressId();
     }
     $this->setData('protect_code', substr(md5(uniqid(\Magento\Framework\Math\Random::getRandomNumber(), true) . ':' . microtime(true)), 5, 6));
     return $this;
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:48,代碼來源:Order.php

示例4: _beforeSave

 /**
  * Before object save
  *
  * @return $this
  */
 protected function _beforeSave()
 {
     parent::_beforeSave();
     if (!$this->getParentId() && $this->getInvoice()) {
         $this->setParentId($this->getInvoice()->getId());
     }
     return $this;
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:13,代碼來源:Comment.php

示例5: _beforeSave

 /**
  * Before object save
  *
  * @return $this
  * @throws \Magento\Framework\Model\Exception
  */
 protected function _beforeSave()
 {
     if ((!$this->getId() || null !== $this->_items) && !count($this->getAllItems())) {
         throw new \Magento\Framework\Model\Exception(__('We cannot create an empty shipment.'));
     }
     if (!$this->getOrderId() && $this->getOrder()) {
         $this->setOrderId($this->getOrder()->getId());
         $this->setShippingAddressId($this->getOrder()->getShippingAddress()->getId());
     }
     return parent::_beforeSave();
 }
開發者ID:Atlis,項目名稱:docker-magento2,代碼行數:17,代碼來源:Shipment.php


注:本文中的Magento\Sales\Model\AbstractModel::_beforeSave方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。