将订单项目添加到Magento中的订单网格

将订单项目添加到Magento中的订单网格,magento,Magento,我正在尝试使用grid.php将订购的产品添加到admin中的订单网格中 app\code\core\Mage\Adminhtml\Block\Sales\Order\Grid.php 我还为此视图添加了另一个客户属性。当我添加产品列表时,找到的订单数总是设置为1,并且它不允许我转到订单的下一页 这是我设法添加的代码 protected function _prepareCollection() { $collection = Mage::getResourceModel($this

我正在尝试使用grid.php将订购的产品添加到admin中的订单网格中

app\code\core\Mage\Adminhtml\Block\Sales\Order\Grid.php
我还为此视图添加了另一个客户属性。当我添加产品列表时,找到的订单数总是设置为1,并且它不允许我转到订单的下一页

这是我设法添加的代码

protected function _prepareCollection()
{
    $collection = Mage::getResourceModel($this->_getCollectionClass());
    $collection->getSelect()->join('sales_flat_order_item', '`sales_flat_order_item`.order_id=`main_table`.entity_id', array('name'  => new Zend_Db_Expr('group_concat(`sales_flat_order_item`.name SEPARATOR ", ")')));
    $collection->getSelect()->group('entity_id');
    $collection->getSelect()->joinLeft(
                array('cev' => 'customer_entity_varchar'),
                '(main_table.customer_id = cev.entity_id AND cev.attribute_id = 141 AND main_table.customer_id IS NOT NULL)',
                array(
                    'admin_number' => 'cev.value',
                )
            );

    $this->setCollection($collection);
    return parent::_prepareCollection();
}

   $this->addColumn('admin_number', array(
            'header' => Mage::helper('sales')->__('Admin Number'),
            'filter_index' => 'cev.value',
            'index' => 'admin_number'
    ));

$this->addColumn('name', array(
        'header'    => Mage::helper('Sales')->__('Products'),
        'width'     => '100px',
        'index'     => 'name',
        'type'        => 'text',

    ));

希望有人能帮我找出问题所在。

$rows=$connection->fetchAll($sql)//fetchRow($sql)、fetchOne($sql)//Zend_Debug::dump($rows)$pk=0;foreach($value形式的行){$pkorder[]=$rows[$pk]['order_id'];$pk++}
    protected function _prepareCollection()
        {
    $userArray = Mage::getSingleton('admin/session')->getData();
    $user = Mage::getSingleton('admin/session');
    $userId = $user->getUser()->getUserId();

    $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
    $sql        = "Select * from sales_flat_order_grid as sss, junaidbhura_jbmarketplace_products as vitem, sales_flat_order_item as item WHERE vitem.product_id = item.product_id and sss.entity_id = item.order_id and vitem.user_id = $userId";
    $rows       = $connection->fetchAll($sql); //fetchRow($sql), fetchOne($sql),...
    //Zend_Debug::dump($rows);
    $pk = 0;
    foreach($rows as $value){
    $pkorder[] = $rows[$pk]['order_id'];
    $pk++;
    }

    //print_r( $pkorder);


    //print_r($userId);
    //die;

            $collection = Mage::getResourceModel($this->_getCollectionClass());
            if($userId == 1 ){ }else{
            $collection->addFieldToFilter('entity_id', array('in' => array( $pkorder )));
            }
            $this->setCollection($collection);
            return parent::_prepareCollection();
        }