0

OpenCart 3.0.2.0 + Journal2 theme.

Problem: when using the search function, the results are sorted by "Default" sort order.

How can I change it to sort by "Name A-Z" (ascending)?

I've found a couple of solutions on SO, but they relate to OC 2.x, not 3.x, and they didn't work when I tried to implement them.

Also, as a bonus, if anyone knows how to disable the "Search in product descriptions" by default, I would really appreciate it.

TomJones999
  • 775
  • 2
  • 13
  • 30
  • if you have not complete your development then i will recommenced you to install 3.0.2.1b its cover all issue of 3.0.2.0 – Prashant Nov 29 '17 at 09:12
  • 1.) We have completed development, and there are too many customizations to start from scratch, for this one feature. 2.) The Release Notes for 3.0.2.1b state "Non production Beta Do not use on a live web site." ... sooooo not going to risk it. – TomJones999 Nov 30 '17 at 18:51

1 Answers1

1

For sort by "Name A-Z" (ascending)

Got to this path

catalog/controller/product/product.php

change code

Original Code

if (isset($this->request->get['sort'])) {
    $sort = $this->request->get['sort'];
} else {
    $sort = 'p.sort_order';
}

Change Only else part

if (isset($this->request->get['sort'])) {
    $sort = $this->request->get['sort'];
} else {
    $sort = 'pd.name';
}

enter image description here For disable the "Search in product descriptions with 2 way.

Solution 1

remove or hide descriptions checkbox, check image below

enter image description here

Solution 2

Got to this path

catalog/controller/product/search.php

Original Code

$filter_data = array(
    'filter_name'         => $search,
    'filter_tag'          => $tag,
    'filter_description'  => $description,
    'filter_category_id'  => $category_id,
    'filter_sub_category' => $sub_category,
    'sort'                => $sort,
    'order'               => $order,
    'start'               => ($page - 1) * $limit,
    'limit'               => $limit
);

Change only one line remove it or comment it.

$filter_data = array(
    'filter_name'         => $search,
    'filter_tag'          => $tag,
    /*'filter_description'  => $description,*/
    'filter_category_id'  => $category_id,
    'filter_sub_category' => $sub_category,
    'sort'                => $sort,
    'order'               => $order,
    'start'               => ($page - 1) * $limit,
    'limit'               => $limit
);

enter image description here

Prashant
  • 347
  • 1
  • 2
  • 12