Umair Zaman
Umair Zaman

Reputation: 351

Pager error in custom collection magento

I have an array populated with some objects that are not from magento. I have fetched them from 3rd party software and I am showing them in magento grid. The grid population is complete. But when I try to add a pager to its collection, it throws an exception. here is the exception text

Magento Error

I have seen on some articles that there is a difference between magento collection and an ordinary array in php. I am new to magento so I require help in it. I have also tried to convert it to magento collection as proposed in

Convert an array to a collection

but its not working either.Any help would be highly appreciated.

Regards

Upvotes: 0

Views: 185

Answers (1)

Dharmesh Thanki
Dharmesh Thanki

Reputation: 420

Please try below code.

protected $collection;
public $collection1;
public $rowObj;
protected function _construct()
{
$currentPage = (empty($_REQUEST['p'])) ? 1 : $_REQUEST['p'];
$setLimit = (empty($_REQUEST['limit'])) ? 9 : $_REQUEST['limit'];
$collection1 = new Varien_Data_Collection(); 
$rowObj = new Varien_Object();
 $this->collection = array_merge($this->getPreviousLead(), $this->getLeadsData()); 
$this->collection = array_merge($this->collection, $this->getContactsData());
 $this->collection = array_merge($this->collection, $this->getUpdateLeads()); 
$this->collection->setPage($currentPage, $setLimit);
$rowObj->setData($this->collection); 

$collection1->addItem($rowObj); 

}

Hope this will work for you!

Cheers!

Upvotes: 2

Related Questions