【问题标题】:Magento - filtering customers based on an EAV (custom) attribute in RMA GridMagento - 根据 RMA Grid 中的 EAV(自定义)属性过滤客户
【发布时间】:2012-06-23 18:05:55
【问题描述】:

我正在使用 Magento 1.4.1.1 和上面的 AW RMA extension

安装此扩展后,我在管理员中看到了 RMA 请求网格和待处理的 RMA 请求网格。

我希望能够根据存储在 customer_entity_varchar

中的 EAV(自定义)属性(例如 customer_referrer_id)过滤此网格中的请求

该扩展有一个表 aw_rma_entity,其中还保存了 customer_id。 RMA Grid 获取如下数据:

$collection = Mage::getModel('awrma/entity')
                ->getCollection();

尝试 1

我已尝试将客户实体与此表连接起来,如下所示:

$collection->getSelect()->join('customer_entity', 'customer_id = customer_entity.entity_id', array('entity_id' => 'customer_entity.entity_id'));

结果 1

这只是显示一个没有网格的页面。如果它起作用了,我会尝试加入 customer_entity_varchar 以在 customer_referrer_id 字段上应用过滤器。


尝试 2

我所做的另一种尝试是先加载客户集合,然后将 RMA 实体数据加入其中,如下代码所示:

$collection = Mage::getResourceModel('customer/customer_collection');

$collection->joinRight('awrma/entity', 'customer_id=entity_id', array('*'));

结果 2

第二次尝试产生以下错误:

错误信息--------------------------------> 项目 (Mage_Customer_Model_Customer) 同 id "XXX" 已存在";

尽管事实上它在similar question for filtering results in the Sales Orders Grid 之后以这种方式对我有用

【问题讨论】:

  • 我会向 Ahead Works 寻求支持。
  • @FlorineChis 我也通过他们的支持论坛向他们寻求帮助,但还没有收到他们的回复。

标签: magento


【解决方案1】:

这可能不是最好的解决方案,但很可能会奏效:

$collection = Mage::getModel('awrma/entity')->getCollection();
$collection->getSelect()->joinInner('customer_entity_varchar', 'customer_id=entity_id', array('attribute_id' =>'attribute_id','value'=>'value') );                
$logged_in_admin = Mage::getSingleton('admin/session')->getUser()->getEmail();  
$customer_referrer_attribute_id = //Set this equal to attribute_id FROM table eav_attribute WHERE attribute_code = "customer_referrer_id"     
$collection->addFieldToFilter('attribute_id', $customer_referrer_attribute_id );
$collection->addFieldToFilter('value', $customer_referrer_id);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多