In PrestaShop, the
protected $_defaultOrderWay variable is used to set the default ordering direction for the listing of records in the back office. By default, it is set to
'DESC', which means that records will be sorted in descending order.
This variable is defined in the
ObjectModel class, which is the parent class of most classes used in PrestaShop. Here’s an example of how to override this variable in a class:
class MyModule extends Module
protected $_defaultOrderWay = 'ASC';
In the above code, we are overriding the
$_defaultOrderWay variable in the
MyModule class and setting it to
'ASC'. This means that records will be sorted in ascending order by default when viewing the listing of records for this module in the back office.
Note that this variable only affects the default sorting order in the back office listing. It does not affect the sorting order when querying records programmatically using SQL queries or the PrestaShop API.