나는 다음을 수행하여 매우 비슷한 일을했습니다
재정의 판매 주문 격자 블록을. 당신이 당신의 자신의 확장을 설정해야합니다 이렇게하려면 (이미이 일을 할 수있는 것 같습니다, 그러나 다만 경우, 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/local/Company/Module/Block/Sales/Order의 내 확장 폴더에 app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php를 입력하십시오.
복사 된 파일 클래스 이름을 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 함수의 두 번째 부분에서 필터링. 필자의 경우 customer_group_id와 customer_email을 그리드에 표시하여 필요할 경우 사용자가 수동으로 필터링 할 수 있도록했습니다.
sales_flat_order 테이블에 customer_group_id가 없습니까? 제 경우에는 제품이 sales_flat_order에 없기 때문에 제게 어려움을 겪고 있습니다. 주문이있는 경우 여러 제품이 연결되어 있으며 모두 'admin_id'속성이 다르므로 하나 이상의 제품이있는 주문 만 표시해야합니다. 'admin_id'는 로그인 한 관리자의 주문입니다. –
당신은 위의 코드를 살펴보면 sales_flat_order 테이블에 왼쪽 조인을 수행하여 $ 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,'왼쪽 '); 당신은 똑같은 일을 할 수 있습니다. – CCBlackburn
위대한, 당신이 말한 것처럼 클래스를 오버라이드해야했지만, 말했듯이 아이템을 필터링 할 수 없었고, 루프를 끝내야 만했습니다. 어쨌든 고마워. –