/** * Set order to result * * @param string $attribute * @param string $dir * @return $this */ public function setOrder($attribute, $dir = self::SORT_ORDER_DESC) { if ($attribute == 'wishlists') { $this->getSelect()->order($attribute . ' ' . $dir); } else { parent::setOrder($attribute, $dir); } return $this; }
/** * Add select order * * @param string $field * @param string $direction * @return \Magento\Framework\Data\Collection\AbstractDb */ public function setOrder($field, $direction = self::SORT_ORDER_DESC) { if ($field == 'product_name') { return $this->setOrderByProductName($direction); } else { if ($field == 'days_in_wishlist') { $field = 'added_at'; $direction = $direction == self::SORT_ORDER_DESC ? self::SORT_ORDER_ASC : self::SORT_ORDER_DESC; } return parent::setOrder($field, $direction); } }