Exemplo n.º 1
0
 /**
  * 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;
 }
Exemplo n.º 2
0
 /**
  * Add select order
  *
  * The $field parameter is properly quoted, lately it was treated field "order" as special SQL
  * word and was not working
  *
  * @param string $field
  * @param string $direction
  * @return $this
  */
 public function setOrder($field, $direction = self::SORT_ORDER_DESC)
 {
     return parent::setOrder($this->getConnection()->quoteIdentifier($field), $direction);
 }