【发布时间】:2017-01-23 18:03:42
【问题描述】:
我正在尝试将自定义表加入到客户集合中。 自定义表是:
+---------+--------------------+
| user_id | linked_customer_id |
+---------+--------------------+
| 4 | 12 |
+---------+--------------------+
我想将 user_id 添加到 customer_id 与linked_customer_id 匹配的每个项目。
我现在收到了以下内容,但我正在收到:
找不到列:1054 未知列“main_table.entity_id”
$collection = Mage::getResourceModel('customer/customer_collection')
->addNameToSelect()
->addAttributeToSelect('entity_id')
->addAttributeToSelect('email')
->addAttributeToSelect('brand')
->addAttributeToSelect('group_id')
->joinAttribute('shipping_company', 'customer_address/company', 'default_shipping', null, 'left')
->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
->joinAttribute('shipping_telephone', 'customer_address/telephone', 'default_shipping', null, 'left')
->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
->joinAttribute('shipping_country_id', 'customer_address/country_id', 'default_shipping', null, 'left')
->joinAttribute('billing_vat_id', 'customer_address/vat_id', 'default_billing', null, 'left');
$collection->getSelect()->joinLeft(
array('salesrep' => 'custom_column' ), 'main_table.entity_id=salesrep.user_id',
array('user_id' => 'salesrep.linked_customer_id')
);
$this->setCollection($collection);
【问题讨论】:
标签: mysql magento zend-framework left-join