示例#1
0
 /**
  * Before object save
  *
  * @return Mage_Sales_Model_Order_Creditmemo_Comment
  */
 protected function _beforeSave()
 {
     parent::_beforeSave();
     if (!$this->getParentId() && $this->getCreditmemo()) {
         $this->setParentId($this->getCreditmemo()->getId());
     }
     return $this;
 }
示例#2
0
 /**
  * Before object save manipulations
  *
  * @return Mage_Sales_Model_Order_Creditmemo
  */
 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 Mage_Core_Model_Abstract
  */
 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 = Mage::getSingleton('eav/config')->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);
     }
     if ($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(mt_rand(), true) . ':' . microtime(true)), 5, 6));
     return $this;
 }
示例#4
0
 /**
  * Before object save
  *
  * @return Mage_Sales_Model_Order_Shipment
  */
 protected function _beforeSave()
 {
     if ((!$this->getId() || null !== $this->_items) && !count($this->getAllItems())) {
         Mage::throwException(Mage::helper('sales')->__('Cannot create an empty shipment.'));
     }
     if (!$this->getOrderId() && $this->getOrder()) {
         $this->setOrderId($this->getOrder()->getId());
         $this->setShippingAddressId($this->getOrder()->getShippingAddress()->getId());
     }
     if ($this->getPackages() && !is_scalar($this->getPackages())) {
         $this->setPackages(serialize($this->getPackages()));
     }
     return parent::_beforeSave();
 }
示例#5
0
 /**
  * Processing object before save data
  *
  * @return Mage_Core_Model_Abstract
  */
 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));
     }
     /**
      * Process items dependency for new order
      */
     if (!$this->getId()) {
         foreach ($this->getAllItems() as $item) {
             if ($parent = $item->getQuoteParentItemId() && !$item->getParentItem()) {
                 $item->setParentItem($this->getItemByQuoteItemId($parent));
             }
         }
     }
     return $this;
 }
示例#6
0
 /**
  * Processing object before save data
  *
  * @return Mage_Core_Model_Abstract
  */
 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));
     }
     /**
      * Process items dependency for new order
      */
     if (!$this->getId()) {
         foreach ($this->getAllItems() as $item) {
             if ($parent = $item->getQuoteParentItemId() && !$item->getParentItem()) {
                 $item->setParentItem($this->getItemByQuoteItemId($parent));
             }
         }
     }
     if ($this->getCustomer()) {
         $this->setCustomerId($this->getCustomer()->getId());
     }
     $this->setData('protect_code', substr(md5(uniqid(mt_rand(), true) . ':' . microtime(true)), 5, 6));
     return $this;
 }
示例#7
0
 protected function _beforeSave()
 {
     if (!count($this->getAllItems())) {
         Mage::throwException(Mage::helper('sales')->__('Cannot create an empty shipment.'));
     }
     return parent::_beforeSave();
 }
 /**
  * Set order again if required
  * @return Mage_Sales_Model_Order_Status_History
  */
 protected function _beforeSave()
 {
     if ($this->_shouldSetOrderBeforeSave) {
         $this->setOrder($this->_order);
     }
     return parent::_beforeSave();
 }