1

カスタムモジュールでは、以下のコードを使用してグリッドビューを取得しました。また、正しいカウントを取得していますが、グリッドには1行しか表示されません。つまり、「合計2レコードが見つかりました」と表示されますが、グリッドには1行しか表示されません。

助けてください。

カスタムモジュールの私のgrid.phpコードは次のとおりです。

public function __construct()
{
    parent::__construct();
    $this->setId(‘order_tailor’);
    $this->setUseAjax(true);
}

/**
* Retrieve collection class
*
* @return string
*/
protected function _getCollectionClass()
{
    return ‘sales/order_invoice_grid_collection’;
}

protected function _prepareCollection()
{
    $collection = Mage::getResourceModel($this->_getCollectionClass())
    ->addFieldToSelect('entity_id')
    ->addFieldToSelect('order_id')
    ->setOrderFilter($this->getOrder())
    ;
    $collection->getSelect()->join('custom_order_info', 'main_table.entity_id = custom_order_info.custom_id',array('tailor_name','created_at','custom_id','id'));
    $collection->getSelect()->group('entity_id');
    $this->setCollection($collection);
    return parent::_prepareCollection();
}

protected function _prepareColumns()
{
   $this->addColumn(‘id’, array(
   ‘header’ => Mage::helper(‘sales’)->__(‘ID’),
   ‘index’ => ‘id’,
   ‘width’ => ’120px’,
   ));

   $this->addColumn(‘tailor_name’, array(
   ‘header’ => Mage::helper(‘sales’)->__(‘Tailor Name’),
   ‘index’ => ‘tailor_name’,
   ));

   $this->addColumn(‘created_at’, array(
   ‘header’ => Mage::helper(‘sales’)->__(‘Date Sent’),
   ‘index’ => ‘created_at’,
   ‘type’ => ‘datetime’,
   ));

   $this->addColumn(‘delivery_at’, array(
   ‘header’ => Mage::helper(‘sales’)->__(‘Date Delivery Expected’),
   ‘index’ => ‘delivery_at’,
   ‘type’ => ‘datetime’,
   ));

   $this->addColumn(‘status’, array(
   ‘header’ => Mage::helper(‘sales’)->__(‘Status’),
   ‘index’ => ‘status’,
   ‘type’ => ‘options’,
   ‘options’ => array(
       1 => ‘Draft’,
       2 => ‘Sent’,
       3 => ‘Accepted’,
      ),
   ));

   $this->addColumn(‘base_grand_total’, array(
   ‘header’ => Mage::helper(‘customer’)->__(‘Amount’),
   ‘index’ => ‘base_grand_total’,
   ‘type’ => ‘currency’,
   ‘currency’ => ‘base_currency_code’,
   ));

   return parent::_prepareColumns();
}

/**
* Retrieve order model instance
*
* @return Mage_Sales_Model_Order
*/
public function getOrder()
{
    return Mage::registry(‘current_order’);
}

public function getRowUrl($row)
{
    return $this->getUrl(‘*/sales_order_test/view’,
    array(
       ‘id’ => $row->getId(),
       ‘order_id’ => $row->getOrderId()
      )
   );
}

public function getGridUrl()
{
    return $this->getUrl(‘*/*/grid’, array(‘_current’ => true));
}
4

2 に答える 2

1

グリッド内の正しいカウントと行を取得するには、コア メソッドをオーバーライドする必要があると思います。Magento グリッドのクエリで「グループ化」を使用している場合、適切に処理されないことがあります。この問題に関する私の投稿を確認して修正することをお勧めします。

http://ka.lpe.sh/2012/01/05/magento-wrong-count-in-admin-grid-when-using-group-by-clause-overriding-lib-module/

于 2013-01-28T10:56:39.077 に答える
0

私はそのような同じ問題を抱えていました!config.xml の構成を見つけて解決しました 、別のDBリソースを設定しました!! そのように:

    <resources>
        <home_write>
            <connection>
                <use>some_setup</use>
            </connection>
        </home_write>
        <home_read>
            <connection>
                <use>some_setup</use>
            </connection>
        </home_read>
    </resources>

default_setupに修正したら解決しました!

于 2015-04-17T08:55:06.147 に答える