public function setAddress(MageQuote $quote)
    {
        $billing = $this->sgBase->getInvoiceAddress();
        if (!empty($billing)) {
            $data = $this->sgCustomer->createAddressData($this->sgBase, $billing, $quote->getCustomerId());
            $quote->getBillingAddress()
                  ->addData($data)
                  ->setCustomerAddressId($billing->getId())
                  ->setCustomerId($this->sgBase->getExternalCustomerId())
                  ->setData('should_ignore_validation', true);
        }

        $shipping = $this->sgBase->getDeliveryAddress();
        if (!empty($shipping)) {
            $data = $this->sgCustomer->createAddressData($this->sgBase, $shipping, $quote->getCustomerId());
            $quote->getShippingAddress()
                  ->addData($data)
                  ->setCustomerAddressId($shipping->getId())
                  ->setCustomerId($this->sgBase->getExternalCustomerId())
                  ->setData('should_ignore_validation', true);
        }

        if (!$quote->getShippingAddress()->getCountryId()) {
            $defaultCountryItem = $this->sgCoreConfig->getConfigByPath(Custom::XML_PATH_GENERAL_COUNTRY_DEFAULT);
            $quote->getShippingAddress()->setCountryId($defaultCountryItem->getValue());
        }
    }
public function setAddress(MageQuote $quote)
    {
        $billing = $this->sgBase->getInvoiceAddress();
        if (!empty($billing)) {
            $data = $this->sgCustomer->createAddressData($this->sgBase, $billing, $quote->getCustomerId());
            $quote->getBillingAddress()
                  ->addData($data)
                  ->setCustomerAddressId($billing->getId())
                  ->setCustomerId($this->sgBase->getExternalCustomerId())
                  ->setData('should_ignore_validation', true);
        }

        $shipping = $this->sgBase->getDeliveryAddress();
        if (!empty($shipping)) {
            $data = $this->sgCustomer->createAddressData($this->sgBase, $shipping, $quote->getCustomerId());
            $quote->getShippingAddress()
                  ->addData($data)
                  ->setCustomerAddressId($shipping->getId())
                  ->setCustomerId($this->sgBase->getExternalCustomerId())
                  ->setData('should_ignore_validation', true);
        }

        if (!$quote->getShippingAddress()->getCountryId()) {
            $defaultCountryItem = $this->sgCoreConfig->getConfigByPath(Custom::XML_PATH_GENERAL_COUNTRY_DEFAULT);
            $quote->getShippingAddress()->setCountryId($defaultCountryItem->getValue());
        }
    }
public function setAddress ( MageQuote $ quote ) { $ billing = $ this -> sgBase -> getInvoiceAddress ( ) ; if ( ! empty ( $ billing ) ) { $ data = $ this -> sgCustomer -> createAddressData ( $ this -> sgBase , $ billing , $ quote -> getCustomerId ( ) ) ; $ quote -> getBillingAddress ( ) -> addData ( $ data ) -> setCustomerAddressId ( $ billing -> getId ( ) ) -> setCustomerId ( $ this -> sgBase -> getExternalCustomerId ( ) ) -> setData ( 'should_ignore_validation' , true ) ; } $ shipping = $ this -> sgBase -> getDeliveryAddress ( ) ; if ( ! empty ( $ shipping ) ) { $ data = $ this -> sgCustomer -> createAddressData ( $ this -> sgBase , $ shipping , $ quote -> getCustomerId ( ) ) ; $ quote -> getShippingAddress ( ) -> addData ( $ data ) -> setCustomerAddressId ( $ shipping -> getId ( ) ) -> setCustomerId ( $ this -> sgBase -> getExternalCustomerId ( ) ) -> setData ( 'should_ignore_validation' , true ) ; } if ( ! $ quote -> getShippingAddress ( ) -> getCountryId ( ) ) { $ defaultCountryItem = $ this -> sgCoreConfig -> getConfigByPath ( Custom :: XML_PATH_GENERAL_COUNTRY_DEFAULT ) ; $ quote -> getShippingAddress ( ) -> setCountryId ( $ defaultCountryItem -> getValue ( ) ) ; } }
Sets Billing and Shipping addresses to quote

@param MageQuote $quote

@throws \Magento\Framework\Exception\LocalizedException
Sets Billing and Shipping addresses to quote