I am converting an Array to Magento2 Collection
$items = $this->getItems();
$collection = $this->collectionFactory->create();
foreach ($items as $item) {
$varienObject = new \Magento\Framework\DataObject();
$varienObject->setData($item);
$collection->addItem($varienObject);
}
return $collection
Now When I apply pagination on this collection
$pager->setLimit(5)->setShowPerPage(true);
Not working it is showing all the records on one page although setavailable limit is showing correct values.
Here is my code for applying pagination
if ($this->Test()) {
$pager = $this->getLayout()->createBlock('Magento\Theme\Block\Html\Pager', 'productpartsfinder.bysize.pager')->setAvailableLimit(array(5 => 5, 10 => 10, 15 => 15, 20 => 20));
$pager->setLimit(5)->setShowPerPage(true);
$pager->setCollection($this->Test());
$this->setChild('pager', $pager);
$this->Test()->load();
}
return parent::_prepareLayout()