/** * @param int $addressId * @param string $addressType * * @return ShopgateAddress */ protected function _getAddress($addressId, $addressType) { $addressItem = new ShopgateAddress(); /** @var AddressCore $addressCore */ $addressCore = new Address($addressId); $addressItem->setId($addressCore->id); switch ($addressType) { case ShopgateCustomerPrestashop::DEFAULT_CUSTOMER_ADDRESS_IDENTIFIER_DELIVERY: $addressItem->setIsDeliveryAddress(true); break; case ShopgateCustomerPrestashop::DEFAULT_CUSTOMER_ADDRESS_IDENTIFIER_INVOICE: $addressItem->setIsInvoiceAddress(true); break; } $addressItem->setFirstName($addressCore->firstname); $addressItem->setLastName($addressCore->lastname); $addressItem->setCompany($addressCore->company); $addressItem->setStreet1($addressCore->address1); $addressItem->setStreet2($addressCore->address2); $addressItem->setZipcode($addressCore->postcode); $addressItem->setCity($addressCore->city); $addressItem->setCountry(Country::getIsoById($addressCore->id_country)); $states = State::getStates($this->getPlugin()->getLanguageId()); foreach ($states as $state) { /** @var StateCore $state */ if ($state['id_country'] == $addressCore->id_state) { $addressItem->setState($state->iso_code); } } return $addressItem; }
/** * @param ShopgateAddress|mixed[] $value */ public function setDeliveryAddress($value) { if (!is_object($value) && !$value instanceof ShopgateAddress && !is_array($value)) { $this->delivery_address = null; return; } if (is_array($value)) { $value = new ShopgateAddress($value); $value->setIsDeliveryAddress(true); $value->setIsInvoiceAddress(false); } $this->delivery_address = $value; }
/** * @param ShopgateCustomer $shopgateCustomer * @param Mage_Customer_Model_Customer $magentoCustomer * @return ShopgateCustomer */ protected function _getCustomerSetAddresses(&$shopgateCustomer, $magentoCustomer) { $aAddresses = array(); foreach ($magentoCustomer->getAddresses() as $magentoCustomerAddress) { /** @var Mage_Customer_Model_Address $magentoCustomerAddress */ $shopgateAddress = new ShopgateAddress(); $shopgateAddress->setId($magentoCustomerAddress->getId()); $shopgateAddress->setIsDeliveryAddress(1); $shopgateAddress->setIsInvoiceAddress(1); $shopgateAddress->setFirstName($magentoCustomerAddress->getFirstname()); $shopgateAddress->setLastName($magentoCustomerAddress->getLastname()); $shopgateAddress->setGender($this->_getCustomerHelper()->getShopgateCustomerGender($magentoCustomerAddress)); $shopgateAddress->setCompany($magentoCustomerAddress->getCompany()); $shopgateAddress->setMail($magentoCustomerAddress->getMail()); $shopgateAddress->setPhone($magentoCustomerAddress->getTelephone()); $shopgateAddress->setStreet1($magentoCustomerAddress->getStreet1()); $shopgateAddress->setStreet2($magentoCustomerAddress->getStreet2()); $shopgateAddress->setCity($magentoCustomerAddress->getCity()); $shopgateAddress->setZipcode($magentoCustomerAddress->getPostcode()); $shopgateAddress->setCountry($magentoCustomerAddress->getCountry()); $shopgateAddress->setState($this->_getHelper()->getIsoStateByMagentoRegion($magentoCustomerAddress)); $aAddresses[] = $shopgateAddress; } $shopgateCustomer->setAddresses($aAddresses); return $shopgateCustomer; }