Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function getShipAddress($customerId){
- $customer = $this->_customerFactory->create()->load($customerId); //insert customer id
- //shipping
- $shippingAddressId = $customer->getDefaultShipping();
- $shippingAddress = $this->_addressFactory->create()->load($shippingAddressId);
- return $shippingAddress;
- }
- public function __construct(
- ...
- MagentoCustomerApiAddressRepositoryInterface $addressRepository,
- MagentoCustomerApiCustomerRepositoryInterface $customerRepository,
- ...
- ) {
- $this->addressRepository = $addressRepository;
- $this->customerRepository = $customerRepository;
- }
- public function getShipCustomer($customerId)
- {
- /** @var MagentoCustomerApiDataCustomerInterface $customer */
- $customer = $this->customerRepository->getById($customerId);
- $shippingAddressId = $customer->getDefaultShipping();
- /** @var MagentoCustomerApiDataAddressInterface $shippingAddress */
- $shippingAddress = $this->addressRepository->getById($shippingAddressId);
- return $shippingAddress;
- }
Add Comment
Please, Sign In to add comment