Question

Comment puis-je ajouter entreprise et le nom du groupe à cette collection

$collection = Mage::getResourceModel('customer/customer_collection')               
               ->addAttributeToSelect('*')             
               ->joinAttribute('billing_street', 'customer_address/street', 'default_billing', null, 'left')
               ->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_fax', 'customer_address/fax', 'default_billing', null, 'left')
               ->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
               ->joinAttribute('billing_country_code', 'customer_address/country_id', 'default_billing', null, 'left')               

               ->joinAttribute('shipping_street', 'customer_address/street', 'default_shipping', null, 'left')
               ->joinAttribute('shipping_postcode', 'customer_address/postcode', 'default_shipping', null, 'left')
               ->joinAttribute('shipping_city', 'customer_address/city', 'default_shipping', null, 'left')
               ->joinAttribute('shipping_telephone', 'customer_address/telephone', 'default_shipping', null, 'left')
               ->joinAttribute('shipping_fax', 'customer_address/fax', 'default_shipping', null, 'left')
               ->joinAttribute('shipping_region', 'customer_address/region', 'default_shipping', null, 'left')
               ->joinAttribute('shipping_country_code', 'customer_address/country_id', 'default_shipping', null, 'left')
               ->joinAttribute('taxvat', 'customer/taxvat', 'entity_id', null, 'left');  
Était-ce utile?

La solution

Entreprise est un attribut customer_address, donc vous devez décider wether il devrait être de l'adresse de livraison ou de facturation ou se joindre à la fois comme le reste.

et le nom du groupe, comme ceci:

$collection->joinTable('customer/customer_group', 'customer_group_id=group_id', array('customer_group_code'), null, 'left');

Je n'ai pas testé; -)

Il est important de définir comme condition la colonne de la table jointe en tant que premier nom.

J'ai écrit un article de blog à ce sujet: http://blog.fabian-blechschmidt.de/articles/Joining-a-flat-table-on-EAV.html

Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange
scroll top