/** * @param array $filterByTypes * @param bool $nonChildrenOnly * @return ImportCollection */ public function getItemsCollection($filterByTypes = array(), $nonChildrenOnly = false) { if (is_null($this->_items)) { $this->_items = $this->_orderItemCollectionFactory->create()->setOrderFilter($this); if ($filterByTypes) { $this->_items->filterByTypes($filterByTypes); } if ($nonChildrenOnly) { $this->_items->filterByParent(); } if ($this->getId()) { foreach ($this->_items as $item) { $item->setOrder($this); } } } return $this->_items; }
/** * Save order related objects * * @return $this */ protected function _afterSave() { if (null !== $this->_addresses) { $this->_addresses->save(); $billingAddress = $this->getBillingAddress(); $attributesForSave = array(); if ($billingAddress && $this->getBillingAddressId() != $billingAddress->getId()) { $this->setBillingAddressId($billingAddress->getId()); $attributesForSave[] = 'billing_address_id'; } $shippingAddress = $this->getShippingAddress(); if ($shippingAddress && $this->getShippigAddressId() != $shippingAddress->getId()) { $this->setShippingAddressId($shippingAddress->getId()); $attributesForSave[] = 'shipping_address_id'; } if (!empty($attributesForSave)) { $this->_getResource()->saveAttribute($this, $attributesForSave); } } if (null !== $this->_items) { $this->_items->save(); } if (null !== $this->_payments) { $this->_payments->save(); } if (null !== $this->_statusHistory) { $this->_statusHistory->save(); } foreach ($this->getRelatedObjects() as $object) { $object->save(); } return parent::_afterSave(); }