Пример #1
0
 /**
  * Before object save manipulations
  *
  * @return $this
  */
 protected function _beforeSave()
 {
     return parent::_beforeSave();
 }
Пример #2
0
 /**
  * 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;
 }
Пример #3
0
 /**
  * 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;
 }
Пример #4
0
 /**
  * Before object save
  *
  * @return $this
  */
 protected function _beforeSave()
 {
     parent::_beforeSave();
     if (!$this->getParentId() && $this->getInvoice()) {
         $this->setParentId($this->getInvoice()->getId());
     }
     return $this;
 }
Пример #5
0
 /**
  * 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();
 }