Hello everybody,
I wonder can anyone help me with a hack where I could make one particular category to use default sorting by PRODUCT DATE ADDED instead of default ordering. This only needs to happen for one category. I don't mind any hard-coding. I don't care about the means I just want a result.
Can anybody help me please
I wonder can anyone help me with a hack where I could make one particular category to use default sorting by PRODUCT DATE ADDED instead of default ordering. This only needs to happen for one category. I don't mind any hard-coding. I don't care about the means I just want a result.
Can anybody help me please
Open catalog/model/catalog/product.php and add a check for category ID to getProducts() function.
Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com
This is how sites turn to junk and then you have to pay more for a decent developer to fix them in future.
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
in your category controller this code sets the sort field and order if given, otherwise it sets the defaults.
You can check for any given category id (12 in example) and set the default to your liking:
Code: Select all
if (isset($this->request->get['sort'])) {
$sort = $this->request->get['sort'];
} else {
$sort = 'p.sort_order';
}
if (isset($this->request->get['order'])) {
$order = $this->request->get['order'];
} else {
$order = 'ASC';
}
You can check for any given category id (12 in example) and set the default to your liking:
Code: Select all
$parts = explode('_', (string)$this->request->get['path']);
$category_id = (int)array_pop($parts);
if (isset($this->request->get['sort'])) {
$sort = $this->request->get['sort'];
} elseif ($category_id == 12) {
$sort = 'p.date_added';
} else {
$sort = 'p.sort_order';
}
if (isset($this->request->get['order'])) {
$order = $this->request->get['order'];
} elseif ($category_id == 12) {
$order = 'ASC';
} else {
$order = 'ASC';
}
DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.
https://www.youtube.com/watch?v=zXIxDoCRc84
Who is online
Users browsing this forum: No registered users and 105 guests