私は、次の手順を実行して、非常に同じようなことをやった:
は、販売注文グリッドブロックをオーバーライドします。あなたがあなた自身の拡張機能を設定する必要がありますこれを行うには(あなたはすでにこれをやっている可能性があるように見えますが、念のため、Magento wikiでいくつかの便利なDOCOあり)
<config>
<modules>
<Company_Module>
<version>0.1.0</version>
</Company_Module>
</modules>
<global>
<blocks>
<company_module>
<class>Company_Module_Block</class>
</company_module>
<adminhtml>
<rewrite>
<sales_order_grid>Company_Module_Block_Sales_Order_Grid</sales_order_grid>
</rewrite>
</adminhtml>
</blocks>
</global>
</config>
私は、コピー/ app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.phpを/ app/code/local/Company/Module/Block/Sales/Orderにある
にコピーします。クラス名をclass Company_Module_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid
に変更しました
次に、_prepareCollection関数を変更しました。この場合、私はsales_flat_orderテーブルからcustomer_group_idとCUSTOMER_EMAILをつかむに興味があった
protected function _prepareCollection() {
$collection = Mage::getResourceModel($this->_getCollectionClass());
// left join onto the sales_flat_order table, retrieving the customer_group_id and customer_email columns -< this can be expanded
$collection->getSelect()->join('sales_flat_order', 'main_table.entity_id=sales_flat_order.entity_id', array('customer_group_id'=>'customer_group_id', 'customer_email'=>'customer_email'), null, 'left');
// grab the current user and get their associated customer groups (additional coding required to associate the customer groups to an admin user
$user = Mage::getSingleton('admin/session')->getUser();
$roleId = implode('', $user->getRoles());
$customerGroupIds = Mage::getModel('admin/roles')->load($roleId)->getCustomerGroupIds();
$orders = Mage::getResourceModel('sales/order_collection');
// if the admin user has associated customer group ids then find the orders associated with those
// this would be where you would do your filtering of the products
if (count($customerGroupIds)) {
$orders->addAttributeToFilter('customer_group_id', array('in' => $customerGroupIds));
}
$orderIds = $orders->getAllIds();
$collection->addAttributeToFilter('entity_id', array('in' => $orderIds));
$this->setCollection($collection);
return parent::_prepareCollection();
}
あなただけ行うことによって、あなたがそれを行うことができるかもしれない... sales_flat_orderテーブルに参加する必要はありません上記の_prepareCollection関数の2番目の部分でフィルタリングします。私の場合、customer_group_idとcustomer_emailをグリッドに表示していましたので、必要に応じてユーザーが手動でフィルタをかけることができました。
sales_flat_orderテーブルのcustomer_group_idはありませんか?私の場合、製品はsales_flat_orderにはありません。なぜなら、それは私には難しいものです。注文がある場合、複数の商品が関連付けられており、すべてが異なる 'admin_id'属性を持っています。ログインした管理者の「admin_id」が1つ以上ある注文のみを表示する必要があります。 –
あなたは絶対に正しいです、上記のコードを見て、sales_flat_orderテーブルに左の結合を行い、 '$ collection-> getSelect() - > join( 'sales_flat_order'、 'main_table.entity_id = sales_flat_order ( 'customer_group_id'、 'customer_group_id'、 'customer_email' => 'customer_email')、null、 'left')) '。あなたは同じことをすることができます – CCBlackburn
素晴らしい、私はあなたが言ったようにクラスをオーバーライドしなければならなかったが、私はあなたが言ったような項目をフィルタリングすることができませんでした。とにかくありがとう。 –