在magento中以网格显示自定义表格数据

时间:2015-02-25 06:23:02

标签: magento

您好请告诉我如何在网格中显示自定义表格数据

这是我的代码,请帮助我。

受保护的函数_prepareCollection(){

 //$collection = Mage::getModel('multivendor/advertisement_advertisementproduct')->getCollection();
//print_r($collection);  die("worigns");
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
 $sql        = "Select * from adv_spaces";
 $rows       = $connection->fetchAll($sql); //fetchRow($sql), fetchOne($sql),...
// Zend_Debug::dump($rows);
 $this->setCollection($connection);       
return parent::_prepareCollection();

}

1 个答案:

答案 0 :(得分:1)

magento方向查询

$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
 $sql        = "Select * from adv_spaces";
 $rows       = $connection->fetchAll($sql); 

应该不起作用。对于网格集合,您需要正确的Magento Model Resource Collection。就像

一样
$collection = Mage::getRescourceModel('sales/order_grid_collection');

Please study here