I’m looking to join all customer address attributes onto the full customer collection.
$collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*');
$collection->joinField('is_active', 'customer/address', 'is_active','parent_id=entity_id');
gives me the fatal error:
Mage_Core_Exception: Can't retrieve entity config: customer/address in /app/Mage.php on line 563
As I’m using Enterprise, we have the ability to add customer address attributes, so using the method of joining specific address attributes is not satisfactory like in this code snippet:
$collection->addNameToSelect()
->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left')
Any ideas? Thank you.
I managed to find a way, although it’s not super elegant but it works for me. Basically, we can cycle through all of the address attributes and add our
joinAttribute()s that way.Note that we ignoring attributes without labels as I only want “real” customer address information.