/**
  * Set collection to pager
  *
  * @param \Magento\Framework\Data\Collection $collection
  * @return $this
  */
 public function setCollection($collection)
 {
     $this->_collection = $collection;
     $this->_collection->setCurPage($this->getCurrentPage());
     // we need to set pagination only if passed value integer and more that 0
     $limit = (int) $this->getLimit();
     if ($limit) {
         $this->_collection->setPageSize($limit);
     }
     if ($this->getCurrentOrder()) {
         $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
     }
     return $this;
 }
Example #2
0
 /**
  * Set Query limit
  *
  * @param int $offset
  * @param int $size
  * @return void
  */
 public function setLimit($offset, $size)
 {
     $this->collection->setPageSize($size);
     $this->collection->setCurPage($offset);
 }