How to use query to get result in Magento admin grid & set into collection?
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$query="MY_SQL_QUERY";
$result = $readConnection->fetchAll($query);
$this->setCollection($result);
This is showing error as Call to a member function setPageSize() on a non-object
Best Answer
$result
is not an object of magento library classVarien_Data_Collection
.SetPageSize()
works whenever a collection is instance ofVarien_Data_Collection
class.If you want to use this function then you need convert you that collection
($result )
toVarien_Data_Collection
.Then setPageSize() will work.See more detail Check out Alan Storm blog