本文整理汇总了PHP中Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection::setOrder方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractCollection::setOrder方法的具体用法?PHP AbstractCollection::setOrder怎么用?PHP AbstractCollection::setOrder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
的用法示例。
在下文中一共展示了AbstractCollection::setOrder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setCollection
/**
* 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;
}
示例2: setOrder
/**
* 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);
}