Author Topic: Default sort order?  (Read 19222 times)

Offline MLCS

  • Newbie
  • *
  • Posts: 28
  • Karma: +3/-0
    • View Profile
    • My Little Crystal Shop
Default sort order?
« on: July 18, 2012, 02:04:35 PM »
Hello. I have just stated using AbanteCart and I have no problems what so ever!
However...I am just wondering if it is possible to change the default "sort order" from the "Model ID" so it is automatically "A-Z"

Thanks for any help :)

Offline Mayank

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Default sort order?
« Reply #1 on: July 18, 2012, 03:24:00 PM »
you can do by  changing database field
of product id and sort order
in special product file order file product file
category file and manufacturer file

Offline MLCS

  • Newbie
  • *
  • Posts: 28
  • Karma: +3/-0
    • View Profile
    • My Little Crystal Shop
Re: Default sort order?
« Reply #2 on: July 18, 2012, 03:41:35 PM »
Which Database table?

Offline MLCS

  • Newbie
  • *
  • Posts: 28
  • Karma: +3/-0
    • View Profile
    • My Little Crystal Shop
Re: Default sort order?
« Reply #3 on: July 30, 2012, 01:14:30 PM »
Im still needing help with this

Offline abantecart

  • Administrator
  • Hero Member
  • *****
  • Posts: 4358
  • Karma: +298/-10
    • View Profile
    • Ideal Open Source Ecommerce Solution
Re: Default sort order?
« Reply #4 on: July 30, 2012, 10:12:29 PM »
Assuming you refer to storefront, Keep in mind that by default sorting is based on the sort order set in the product field

Sorting set based on the SQL select and order clause set in it. Look into file with model public_html/storefront/model/catalog/product.php

Hope this help.
Please  rate your experience or leave your review
We need your help to build better free open source ecommerce platform for everyone. See how you can help

Offline MLCS

  • Newbie
  • *
  • Posts: 28
  • Karma: +3/-0
    • View Profile
    • My Little Crystal Shop
Re: Default sort order?
« Reply #5 on: July 31, 2012, 01:21:35 PM »
Not really. Theres a lot of PHP in there and I cant see where I have to change.

Offline abantecart

  • Administrator
  • Hero Member
  • *****
  • Posts: 4358
  • Karma: +298/-10
    • View Profile
    • Ideal Open Source Ecommerce Solution
Re: Default sort order?
« Reply #6 on: August 01, 2012, 06:34:12 AM »
There are different functions that are called to get listing of products. This depends on the section that does listing.

Example:

public function getProductsByCategoryId($category_id, $sort = 'p.sort_order', $order = 'ASC', $start = 0, $limit = 20) {

There is a section that sets the sorting (order)

                $sort_data = array(
                        'pd.name',
                        'p.sort_order',
                        'p.price',
                        'special',
                        'rating'
                );

                if (in_array($sort, $sort_data)) {
                        if ($sort == 'pd.name') {
                                $sql .= " ORDER BY LCASE(" . $sort . ")";
                        } else {
                                $sql .= " ORDER BY " . $sort;
                        }
                } else {
                        $sql .= " ORDER BY p.sort_order";
                }

                if ($order == 'DESC') {
                        $sql .= " DESC";
                } else {
                        $sql .= " ASC";
                }


You need to let us know where exactly you need to change the sorting order. What page?
Please  rate your experience or leave your review
We need your help to build better free open source ecommerce platform for everyone. See how you can help

Offline MLCS

  • Newbie
  • *
  • Posts: 28
  • Karma: +3/-0
    • View Profile
    • My Little Crystal Shop
Re: Default sort order?
« Reply #7 on: August 05, 2012, 09:16:51 AM »
When they go into categories. I want to change it so that its A-Z

Offline abantecart

  • Administrator
  • Hero Member
  • *****
  • Posts: 4358
  • Karma: +298/-10
    • View Profile
    • Ideal Open Source Ecommerce Solution
Re: Default sort order?
« Reply #8 on: August 06, 2012, 09:42:19 AM »
You can change the sorting pram to be defaulted to A-Z

Look in file:
storefront/controller/pages/product/category.php

Locate this code:
Quote
            $sorts[] = array(
               'text'  => $this->language->get('text_default'),
               'value' => 'p.sort_order-ASC',
               'href'  => $this->html->getSEOURL('product/category', $url . '&path=' . $this->request->get['path'] . '&sort=p.sort_order&order=ASC', '&encode')
            );

Switch it with next line.
Please  rate your experience or leave your review
We need your help to build better free open source ecommerce platform for everyone. See how you can help

Offline MLCS

  • Newbie
  • *
  • Posts: 28
  • Karma: +3/-0
    • View Profile
    • My Little Crystal Shop
Re: Default sort order?
« Reply #9 on: August 12, 2012, 08:47:33 AM »
Thats made it so it says the sorting is A-Z but it actually isnt. Its still default sorted by Model ID. Ive even removed "Default" from that drop-down and it still sorts it that way....

http://mylittlecrystalshop.com/ab/index.php?rt=product/category&path=4_25

see?

Edit: Seems its being ordered by when its uploaded  ???
« Last Edit: August 12, 2012, 08:53:38 AM by MLCS »

Offline MLCS

  • Newbie
  • *
  • Posts: 28
  • Karma: +3/-0
    • View Profile
    • My Little Crystal Shop
Re: Default sort order?
« Reply #10 on: August 21, 2012, 08:38:18 PM »
someone please help!

Offline abantecart

  • Administrator
  • Hero Member
  • *****
  • Posts: 4358
  • Karma: +298/-10
    • View Profile
    • Ideal Open Source Ecommerce Solution
Re: Default sort order?
« Reply #11 on: August 22, 2012, 12:10:36 PM »
In the same spot, can you please change
'href'  => $this->html->getSEOURL('product/category', $url . '&path=' . $this->request->get['path'] . '&sort=p.sort_order&order=ASC', '&encode')
TO:
'href'  => $this->html->getSEOURL('product/category', $url . '&path=' . $this->request->get['path'] . '&sort=pd.name&order=ASC', '&encode')

Correct link should be this to force sort by name like below:
http://mylittlecrystalshop.com/shop/index.php?rt=product/category&path=4_25&sort=pd.name-ASC

This should fix default sorting, if not, let us know.
Please  rate your experience or leave your review
We need your help to build better free open source ecommerce platform for everyone. See how you can help

Offline MLCS

  • Newbie
  • *
  • Posts: 28
  • Karma: +3/-0
    • View Profile
    • My Little Crystal Shop
Re: Default sort order?
« Reply #12 on: August 26, 2012, 02:47:25 PM »
Found out it wasnt that.
Had to change
Code: [Select]
if (isset($this->request->get['sort'])) {
list($sort,$order) = explode("-",$this->request->get['sort']);
} else {
$sort = 'p.sort_order';
}

to
Code: [Select]
if (isset($this->request->get['sort'])) {
list($sort,$order) = explode("-",$this->request->get['sort']);
} else {
$sort = 'pd.name';
}
in the same file.

Just so it helps you in the future :)
« Last Edit: August 26, 2012, 02:51:34 PM by MLCS »

 

Powered by SMFPacks Social Login Mod