3
这是我第一个使用Magento 2的项目。我很难获取登录客户的默认结算/送货地址以显示在我的前端自定义模块。获取登录客户的默认帐单/发货地址Magento 2.0
到目前为止,我有这样的:
//this gets the billing id which is an integer. I'm thinking it must be loaded to get the whole data of the address
$billingId = $customerSession->getCustomer()->getDefaultBilling();
//just found this in the internet and thought it might be the same as loading an order, but it doesn't work
$address = $objectManager->create('\Magento\Customer\Model\AddressFactory')->load($billingId);
但错误说: Call to undefined method Magento\Customer\Model\AddressFactory::load()
我想我接近,但我不知道下一步该怎么做。提前致谢。
它的工作!谢谢! :D – Ian
直接使用对象管理器不是好习惯。 更重要的是,这里应该使用适当的地址存储库。 –
而不是指出“错误”的方式来做到这一点,然后只是留下为什么不写一个真正支持如何实施的建议。 – LefterisL