Guest User

Untitled

a guest
Dec 12th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. public function getShipAddress($customerId){
  2. $customer = $this->_customerFactory->create()->load($customerId); //insert customer id
  3.  
  4. //shipping
  5. $shippingAddressId = $customer->getDefaultShipping();
  6. $shippingAddress = $this->_addressFactory->create()->load($shippingAddressId);
  7.  
  8. return $shippingAddress;
  9. }
  10.  
  11. public function __construct(
  12. ...
  13. MagentoCustomerApiAddressRepositoryInterface $addressRepository,
  14. MagentoCustomerApiCustomerRepositoryInterface $customerRepository,
  15. ...
  16. ) {
  17. $this->addressRepository = $addressRepository;
  18. $this->customerRepository = $customerRepository;
  19. }
  20.  
  21. public function getShipCustomer($customerId)
  22. {
  23. /** @var MagentoCustomerApiDataCustomerInterface $customer */
  24. $customer = $this->customerRepository->getById($customerId);
  25.  
  26. $shippingAddressId = $customer->getDefaultShipping();
  27. /** @var MagentoCustomerApiDataAddressInterface $shippingAddress */
  28. $shippingAddress = $this->addressRepository->getById($shippingAddressId);
  29.  
  30. return $shippingAddress;
  31. }
Add Comment
Please, Sign In to add comment