The
two
methods
that
add
sorting
to
collections
inherited
from
the
\Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection class are setOrder
and addOrder. These methods allow adding one or more order clauses to a collection query.
The setSorting and addSorting methods do not exist in Adobe Commerce.
Verified Reference: [Adobe Commerce Developer Guide - Collections]
In
Magento
2,
collections
inherited
from
\Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection class can be sorted
using the setOrder and addOrder methods. The setOrder method is used to set the order for a field in
the collection, specifying the field by which to sort and the direction of the sorting (ASC or DESC).
The addOrder method is similar but allows for adding multiple sorting orders to the collection,
enabling more complex sorting scenarios. There are no setSorting or addSorting methods in the
standard Magento 2 collection classes.