Вопрос

Как добавить название компании и группы в эту коллекцию

$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');  
Это было полезно?

Решение

Компания является атрибутом Customer_Address, поэтому вы должны решить, должно ли это быть по адресу доставки или выставления счетов или присоединиться к обоим, как и остальные.

И название группы, как это:

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

Не проверил это ;-)

Важно установить в качестве условия столбец соединенной таблицы в качестве имени.

Я написал статью об этом в блоге: http://blog.fabian-blechschmidt.de/articles/joining-a-flat-table-on-eav.html

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