I can’t find a way to paginate my entities in magento 2. I have this code :
JavaScript
x
public function getPosts()
{
if (!$this->hasData('posts')) {
$posts = $this->_postCollectionFactory->create()->addOrder(
PostInterface::CREATED,
PostCollection::SORT_ORDER_DESC
);
$this->setData('posts', $posts);
}
return $this->getData('posts');
}
in magento 1.x i had custom block which had “page/html_pager” type but I can’t find in magento 2 documentation a way to paginate my entities … I fetch them from my block controller (code above).
Advertisement
Answer
Refer following link, in that example pagination is added.
http://www.mage-world.com/blog/create-the-news-list-page-via-frontend-in-magento-2.html