Allows you to add a custom sorting field support to the
Shop_Category::list_products() method.
The event handler should accept two parameters: the sorting column name and the product category object.
It should return the sorting query. This event is often used with
shop:onGetProductSortColumns
to add a custom sorting query for a custom sort field:
public function subscribeEvents()
{
Backend::$events->addEvent('shop:onGetProductSortColumns', $this, 'get_sorting_columns');
Backend::$events->addEvent('shop:onGetCategoryProductSortingQuery', $this, 'get_sorting_query');
}
public function get_sorting_columns()
{
return array('x_newfield');
}
public function get_sorting_query($column, $category)
{
if ($column != 'x_newfield')
return null;
$sort_str = ' custom sorting clause ';
return $sort_str;
}