Вопрос

I was developing a custom shipping module using

Mage::getModel('customer/address')->getCollection()->setCustomerFilter($sellerIDVar)

Using this code broke the page or module. Could you please anybody find the problem ?

I'm using Magento 1.9.4.1

EDIT


I wanted the default billing or default shipping address set of the customer. So when i get the collection with entity_type_id filtered, theres no address !!!

And when i use the Load method, i get all addresses of the customer. So im in trouble with both methods.

helps solicited dears.

Это было полезно?

Решение

Use below code instead of your code, if you want to use same line of statement then @leo comment is right. you should use addFieldToFilter('parent_id',$sellerIDVar). I prefer you follow below code in order to fetch customer address info.

The address information is stored within the Mage_Customer_Model_Customer so you should be able to create an instance of it with the customer id.

$customer = Mage::getModel('customer/customer')->load($sellerIDVar);

Then depending on the type of address that you are looking for you should be able to call one of the following functions.

Primary Billing Address:

$customer->getPrimaryBillingAddress(); 

Primary Shipping Address:

$customer->getPrimaryShippingAddress(); 

General Address Selection:

$customer->getAddressItemById();

I hope this will help

Лицензировано под: CC-BY-SA с атрибуция
Не связан с magento.stackexchange
scroll top