Exemplo n.º 1
0
 /**
  * @magentoDataFixture Magento/Sales/_files/order.php
  * @magentoDataFixture Magento/Customer/_files/customer.php
  * @magentoDataFixture Magento/Customer/_files/customer_address.php
  */
 public function testSave()
 {
     /** @var \Magento\Sales\Model\Order $order */
     $order = Bootstrap::getObjectManager()->create('Magento\\Sales\\Model\\Order');
     /** @var \Magento\Customer\Service\V1\CustomerAddressServiceInterface $customerAddressService */
     $customerAddressService = Bootstrap::getObjectManager()->get('Magento\\Customer\\Service\\V1\\CustomerAddressServiceInterface');
     $order->loadByIncrementId('100000001');
     $this->_model->setOrder($order);
     $this->_model->setCustomerAddressData($customerAddressService->getAddress(1));
     $this->_model->save();
     $this->assertEquals($order->getId(), $this->_model->getParentId());
     $this->assertEquals($this->_model->getCustomerAddressId(), 1);
 }
Exemplo n.º 2
0
 /**
  * Convert order address to quote address
  *
  * @param   \Magento\Sales\Model\Order\Address $address
  * @return  \Magento\Sales\Model\Quote\Address
  */
 public function addressToQuoteAddress(\Magento\Sales\Model\Order\Address $address)
 {
     $quoteAddress = $this->_quoteAddressFactory->create()->setStoreId($address->getStoreId())->setAddressType($address->getAddressType())->setCustomerId($address->getCustomerId())->setCustomerAddressId($address->getCustomerAddressId());
     $this->_objectCopyService->copyFieldsetToTarget('sales_convert_order_address', 'to_quote_address', $address, $quoteAddress);
     return $quoteAddress;
 }
Exemplo n.º 3
0
 /**
  * Import address data from order address
  *
  * @param   \Magento\Sales\Model\Order\Address $address
  * @return $this
  * @deprecated Use \Magento\Sales\Model\Quote\Address::importCustomerAddressData() instead
  */
 public function importOrderAddress(\Magento\Sales\Model\Order\Address $address)
 {
     $this->setAddressType($address->getAddressType())->setCustomerId($address->getCustomerId())->setCustomerAddressId($address->getCustomerAddressId())->setEmail($address->getEmail());
     $this->_objectCopyService->copyFieldsetToTarget('sales_convert_order_address', 'to_quote_address', $address, $this);
     return $this;
 }