Default order in backend product listing

  • Posts: 2143
  • Thank you received: 747
4 years 5 months ago #324118

-- HikaShop version -- : 4.3.0
-- Joomla version -- : 3.9.x
-- PHP version -- : 7.2.x

Hi,

I need to change the default order of the backend product listing to display in descending order of a custom product field on initial page load, of course, without affecting user's ability to change sort order by clicking table headers, etc.

Certain that it happens in /administrator/components/com_hikashop/views/product/view.html.php, I tried replacing the first occurrence of

$order = '';
with
$order = ' ORDER BY b.product_xyz DESC';
(where obviously "product_xyz" is my custom product field), as well as trying a few other other things.

But no joy. So, I'd be grateful for a hint where it can be done -- many thanks in advance!


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )

Please Log in or Create an account to join the conversation.

  • Posts: 83407
  • Thank you received: 13500
  • MODERATOR
4 years 5 months ago #324128

Hi,

It's that line you need to change :
$pageInfo->filter->order->value = $app->getUserStateFromRequest( $this->paramBase.".filter_order", 'filter_order', 'b.order_id','cmd' );
to:
$pageInfo->filter->order->value = $app->getUserStateFromRequest( $this->paramBase.".filter_order", 'filter_order', 'b.product_xyz','cmd' );

The following user(s) said Thank You: lousyfool

Please Log in or Create an account to join the conversation.

  • Posts: 2143
  • Thank you received: 747
4 years 5 months ago #324139

Thanks for your reply, Nicolas.

Actually, the line you mentioned doesn't exist exactly like that, but it's

$pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase.".filter_order", 'filter_order', 'a.ordering', 'cmd');
// change to
$pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase.".filter_order", 'filter_order', 'b.product_xyz', 'cmd');

// and

$pageInfo->filter->order->dir	= $app->getUserStateFromRequest($this->paramBase.".filter_order_Dir", 'filter_order_Dir', 'asc', 'word');
// change to
$pageInfo->filter->order->dir	= $app->getUserStateFromRequest($this->paramBase.".filter_order_Dir", 'filter_order_Dir', 'desc', 'word');
in the "public function listing".

Anyway, you gave me the right pointer, so many thanks for that!


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )

Please Log in or Create an account to join the conversation.

Time to create page: 0.057 seconds
Powered by Kunena Forum