Post by prototype0104 » Sat Nov 23, 2019 5:03 am

Hi guys! I'm using OC 3.0.3.2 with journal 3. I'm trying to sort products in category pages by quantity but I have some issues.
Changed p.sort_order (default sort) to p.quantity in category.php but category page is not loading products sorted by quantity, it's loading sorted A-Z.. If I'm changing to A-Z sort and back to Default products are sorted by quantity ..Any ideas? I tried to modify in model/journal3/product/filter.php but no result.

New member

Posts

Joined
Sun Mar 24, 2019 6:08 pm

Post by Johnathan » Sat Nov 23, 2019 10:39 pm

If you're using Journal 3, and they modify the search code, you'll need to ask the Journal team how to do this. The normal file for loading products is this one:

/catalog/model/catalog/product.php

Image
Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by letxobnav » Sat Nov 23, 2019 11:16 pm

in addition to changing the "default" link, you also need to change the default setting for when no sort is present in the GET variables:

controller catalog.php

Code: Select all

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

Code: Select all

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

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Active Member
Online

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by prototype0104 » Mon Nov 25, 2019 5:05 pm

Thank you!
But not working .. :-\

In catalog.php:

Code: Select all

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

		if (isset($this->request->get['order'])) {
			$order = $this->request->get['order'];
		} else {
			$order = 'DESC';
		}

Code: Select all

$data['sorts'][] = array(
			'text'  => $this->language->get('text_default'),
			'value' => 'p.quantity-DESC',
			'href'  => $this->url->link('product/catalog', '&sort=p.quantity&order=DESC' . $url),
		);
In category.php:

Code: Select all

$data['sorts'][] = array(
				'text'  => $this->language->get('text_default'),
				'value' => 'p.quantity-DESC',
				'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.quantity&order=DESC' . $url)
			);

New member

Posts

Joined
Sun Mar 24, 2019 6:08 pm

Post by paulfeakins » Mon Nov 25, 2019 8:13 pm

prototype0104 wrote:
Mon Nov 25, 2019 5:05 pm
But not working .. :-\
As Johnathan said, if you use Journal, the search will not be using the normal file.

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Expert Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom

Post by prototype0104 » Mon Nov 25, 2019 8:52 pm

Any ideas where to find the code?

New member

Posts

Joined
Sun Mar 24, 2019 6:08 pm
Who is online

Users browsing this forum: thekrotek and 39 guests