I've checked through a fair bit of posts in the forums but haven't been able to get a solution for being able to naturally sort
the text values for a product in a page in my site on loading of the page. The page I'm working in is used to show the back issues
for the client we work with. The intended functionality is showing the latest added issue, with earlier issues being sorted to the end.
It was functioning fine with using the model as the way to sort the items up until we hit model CUS100. Now that the model number is in
the 100 range, when the model sort is applied, CUS100 is being listed in with the CUS10 and CUS11 products. I know about changing the
default sort in the category.php file and to that end I've tried a few different solutions to this problem. The one that looked the most
promising was sorting by both the model and sort order for the product. The sort order for the products from CUS1-CUS99 is set to be 1, while
the CUS100 product is set to a sort order of 0. Running the query in our database returns the products in the correct sort order, with the
CUS100 product showing up first and then CUS99, CUS98, and so on. But when I tried to add the query into the category page, the page loaded
a completely different order for the products.
Here is an example of what I changed in the category.php file to try this out:
original section:
Code: Select all
$data['sorts'][] = array(
'text' => $this->language->get('text_default'),
'value' => 'p.model-DESC',
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.sort_order&order=DESC' . $url)
);
changed section:
Code: Select all
$data['sorts'][] = array(
'text' => $this->language->get('text_default'),
'value' => 'p.sort_order,p.model-DESC',
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.sort_order,p.model&order=DESC' . $url)
);
Wanted to post in the forum to ask if there is something I'm missing in getting this set up. I know that natural sort is a common sql problem
but a lot of the solutions that were presented to me look as though they will not work within the framework of OpenCart. Let me know if anyone
has sugestions to fix this issue.