1

I have this block with pagination:

        protected function _prepareLayout()
        {
            parent::_prepareLayout();
            $this->pageConfig->getTitle()->set(__('Table'));


            if ($this->getItem()) {
                $pager = $this->getLayout()->createBlock(
                    'Magento\Theme\Block\Html\Pager',
                    'Module.pagination.pagination.pager'
                )->setAvailableLimit(array(10=>10,15=>15,50=>50,100=>100))->setShowPerPage(true)->setCollection(
                    $this->getItem()
                );

                $this->setChild('pager', $pager);
                $this->getItem()->load();
            }

            return $this;

        }
        public function getItem()
        {
$obj = \Magento\Framework\App\ObjectManager::getInstance();
            $attributeSetCollectionFactory = $obj->get('Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory');
            /** @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection $attributeSetCollection */
            $attributeSetCollection = $attributeSetCollectionFactory->create();
            $attributeSets = $attributeSetCollection->getItems();

            return $attributeSetCollection;
        }

        public function getPagerHtml()
        {
            return $this->getChildHtml('pager');
        }


    }

And in my template I have this under the table:

 <?php if ($block->getPagerHtml()): ?>
        <div class="order-products-toolbar toolbar bottom"><?php echo $block->getPagerHtml(); ?></div>
    <?php endif ?>

THE PROBLEM IS:

I have 18 items in my table, but I set to show only 10 per page, but, nothings happen, the page reload, but continue showing 10. what I'm doing wrong?

EDIT: I remove the set size and continue the same issue

  • I think you should remove this $attributeSetCollection->setPageSize($pageSize); $attributeSetCollection->setCurPage($page); from your getItem method and let the pagination work it's magic. – Marius Feb 20 at 12:22
  • i removed, and run cache flush and clean, and continue the same, and i dont understand why :( – FlávioD Feb 20 at 12:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.