相关疑难解决方法(0)

如何从eav_attribute表获取实体(例如客户)的数据,以显示在Customer Grid for admin中

我已经扩展了Magento的客户信息表,为客户存储了一个额外的属性.让我们称之为'customer_referrer_id'.

我有一个角色'推荐人',他只能访问客户网格和订单网格.但是,我想限制一个引荐来者只看到网格中那些将customer_referrer_id设置为已登录的引用者ID的客户.同样,对于订单,登录的引用者应该只能看到客户提出的那些订单.拥有customer_referrer_id = loggedin_referrer_id.

我已经知道如何覆盖模块,我必须主要覆盖Adminhtml/Block/Customer/Grid :: _ prepareCollection和Adminhtml/Block/Sales/Order/Grid :: _ prepareCollection

我正在使用Magento 1.4.1.1

这是app/etc/modules/Myproject_Adminhtml中的模块声明文件

<?xml version="1.0"?>

<config>
    <modules>
        <Myproject_Adminhtml>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Mage_Sales />
            </depends>
        </Myproject_Adminhtml>
    </modules>
</config>
Run Code Online (Sandbox Code Playgroud)

我在local/Myproject/Adminhtml/etc /中的模块config.xml如下:

<config>
    <modules>
        <Myproject_Adminhtml>
            <version>1.0.0</version>
        </Myproject_Adminhtml>    
    </modules>

    <global>
          <blocks>
            <adminhtml>
                <rewrite>
                <sales_order_grid>Myproject_Adminhtml_Block_Sales_Order_Grid</sales_order_grid>
                <customer_grid>Myproject_Adminhtml_Block_Customer_Grid</customer_grid>
                </rewrite>
            </adminhtml>
        </blocks>
    </global>
</config>
Run Code Online (Sandbox Code Playgroud)

class Myproject_Adminhtml_Block_Customer_Grid extends Mage_Adminhtml_Block_Customer_Grid
{
    protected function _prepareCollection()
    {
        $collection = Mage::getResourceModel('customer/customer_collection')
        ->addNameToSelect()
        ->addAttributeToSelect('email')
        ->addAttributeToSelect('created_at')
        ->addAttributeToSelect('group_id')
        ->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', …
Run Code Online (Sandbox Code Playgroud)

magento e-commerce

5
推荐指数
1
解决办法
9213
查看次数

标签 统计

e-commerce ×1

magento ×1