Zen Cart Logo
Forums / Setting Up Categories, Products, Attributes / Changing sort order of products in attributes controller

Changing sort order of products in attributes controller

Views: 2,264

Results 1 to 10 of 10
2 Jan 2011, 5:43 AM
#1
way10c avatar

way10c

New Zenner

Join Date:
Sep 2009
Posts:
14
Plugin Contributions:
0

Changing sort order of products in attributes controller

Greetings,

I've been adding new products and assigning them attributes. As the number of products in a category increase, it is getting increasingly hard to find them in the list. They are listed by product name. How can I change the sort to item ID#? That way the last ones (or first w/ a reverse sort) are always the ones I need to edit.

Thanks much,

--Allen

14 Apr 2011, 11:05 PM
#2
amirshawn80 avatar

amirshawn80

New Zenner

Join Date:
Jun 2010
Posts:
27
Plugin Contributions:
0

Re: Changing sort order of products in attributes controller

I was wondering if you got any reply to this issue? I am wanting to sort my items by item number in the attributes controller as well.

14 Apr 2011, 11:49 PM
#3
way10c avatar

way10c

New Zenner

Join Date:
Sep 2009
Posts:
14
Plugin Contributions:
0

Re: Changing sort order of products in attributes controller

amirshawn80,

Nope. I never did. I guess no one knows the answer to that problem.

--Allen

15 Apr 2011, 2:10 AM
#4
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Changing sort order of products in attributes controller

/youradmin/attributes_controller.php has this around line 43```php
if ($action == 'new_cat') {
$current_category_id = (isset($_GET['current_category_id']) ? $_GET['current_category_id'] : $current_category_id);
$sql = "select ptc.*
from " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc
left join " . TABLE_PRODUCTS_DESCRIPTION . " pd
on ptc.products_id = pd.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
where ptc.categories_id='" . $current_category_id . "'
order by pd.products_name";
$new_product_query = $db->Execute($sql);
$products_filter = $new_product_query->fields['products_id'];
zen_redirect(zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
}


    order by pd.products_name";
to
    order by pd.products_id";

The same sql in different versions is repeated a couple more times, and you would want to change all of them the same.

Note that this is a non-overridable file, so keep a backup copy in a safe place (somewhere else). I haven't tested this, so it would be good to hear feedback on the idea.
15 Apr 2011, 5:25 AM
#5
amirshawn80 avatar

amirshawn80

New Zenner

Join Date:
Jun 2010
Posts:
27
Plugin Contributions:
0

Re: Changing sort order of products in attributes controller

That didn't seem to work for me. I am trying to get the products in the attributes controller to be sorted by the product model number, that way it is easy to find them.

When I made those changes it didn't affect the sort order. I'm not exactly sure what that actually changed. I was wondering if it is using a default sort order, maybe... I'm pretty lost.

Any help is much appreciated!

15 Apr 2011, 5:33 AM
#6
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Changing sort order of products in attributes controller

I didn't study the file at great length, so that may not have been the area related to the products you want. It is the file that should apply, though. I have to get some sleep now, but you could examine the file to see if there is any other code that looks relevant.

That sql would definitely set the sort order of whatever it was fetching from the db. You previously mentioned wanting to see the latest products, which would be the product id, not the model, to sort on. (If the model numbers are sequential, then they do the same thing as the product id and you can again sort by id for good results.)

Hmm, I guess it was way10c who specifically wanted the latest products...

15 Apr 2011, 5:12 PM
#7
amirshawn80 avatar

amirshawn80

New Zenner

Join Date:
Jun 2010
Posts:
27
Plugin Contributions:
0

Re: Changing sort order of products in attributes controller

I am trying to sort it by the item model number. This would make products a lot easier for us to find. We are putting up one of a kind pieces, and there's going to be thousands of them. Trying to add the attributes is becoming impossible because the items are in random spots. I will try to mess around with that code some more. If you have any more ideas as to what could fix this let me know. I will post if I figure this out myself.

15 Apr 2011, 5:22 PM
#8
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Changing sort order of products in attributes controller

You can order the products by model number in the sql, as long as you are querying the right tables. I would have to get into them to see exactly what is where. That is a very long file, with multiple branches of function, so it will take some sleuthing. I would suggest looking at view source on the Attributes Controller page to see any classes or tags for the section of interest, then searching for those in the file.

15 Apr 2011, 8:32 PM
#9
amirshawn80 avatar

amirshawn80

New Zenner

Join Date:
Jun 2010
Posts:
27
Plugin Contributions:
0

Re: Changing sort order of products in attributes controller

I am still having no luck. I don't know SQL coding at all, and I think this problem is just a little over my head. I think this would be a good thing to include in the admin attribute settings page. I am surprised there hasn't been many other people with this same issue.

I think it has to do with the products_filter but I am not sure where the settings for the products_filter are located.

Thanks for your help, I will keep checking back to see if anyone can figure this out.

8 Nov 2011, 11:21 PM
#10
datax avatar

datax

New Zenner

Join Date:
Jun 2006
Posts:
37
Plugin Contributions:
0

Re: Changing sort order of products in attributes controller

Some time has past. Maybe somebody found the answer and want to share it with us.
Sort order by products_id or by date_added is what I'm looking for.