I am building an extension for Magento 2. I am trying to get the collection (origin) address of the store.
2 Answers
Here what I tried and it's working:
$this->scopeConfig->getValue(
"general/store_information/street_line1",
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
Please use below code it will give you address customer id
wise.
$customerId = $_POST["customer_id"];
$customer = $this->_customerRepository->getById($customerId);
$addresses = $customer->getAddresses();
Please note that getAddresses will return an array of Magento\Customer\Api\Data\AddressInterface
.
If you need the default billing address you can call:
$billingAddress = $customer->getDefaultBilling();
Thanks and Happy Coding.
-
Thank you, this will return the address of the customer, but I need the shipping address of the store. Commented Oct 28, 2020 at 16:42
-
Then you need to change getDefaultShipping(). Other code is same. Commented Oct 29, 2020 at 3:58