我只需要加载magento collection中不活跃的客户。
$collection = Mage::getModel('customer/customer')
->getCollection()
->addNameToSelect()
->addAttributeToSelect('email')
->addAttributeToSelect('created_at')
->addAttributeToSelect('group_id')
->addAttributeToSelect('confirmation')
->addAttributeToSelect('*');`
$collection
->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');
我试图从这个集合中添加
$collection->getSelect()->where("e.is_active = 0 ");
但是它抛出异常,我不能只加载admin自定义模块内的非活动客户。请帮我加载不活跃的客户。
注意:默认情况下,从前端开始,我将所有客户注册为"is_active"设置为0,因此在管理员批准后,只有客户将被激活。为此,我需要加载所有不活跃的客户。
尝试$collection->addAttributeToFilter('is_active', 0)
根据这个magento线程,客户实体的默认属性的定义可能存在错误。试着用这种方法查看Mage_Customer_Model_Entity_Customer
:
protected function _getDefaultAttributes()
{
return array(
'entity_type_id',
'attribute_set_id',
'created_at',
'updated_at',
'increment_id',
'store_id',
'website_id'
);
}
应该有:
protected function _getDefaultAttributes()
{
return array(
'entity_type_id',
'attribute_set_id',
'created_at',
'updated_at',
'increment_id',
'store_id',
'website_id',
'is_active'
);
}
如果是这种情况,那么Zyava的解决方案既不是这个:$collection->addFieldToFilter('is_active', 0)
可能不行