[Products] Sorting by field definitions does not work

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
nicmare
Power Poster
Power Poster
Posts: 1150
Joined: Sat Aug 25, 2007 9:55 am

[Products] Sorting by field definitions does not work

Post by nicmare »

i am using products (2.7.5) and company directory (1.5.4) with CMSms 1.7.1.

I am using products with summary Template only. i added field definition "rating" with dropdown values from 1-5. they will be displayed in front and backend both.

now, i wanted products to sort the items by this value. therefore i am using the parameter sortby="f:rating" but the sort order is wrong. they are completely disordered for some reason?!

i am using the same sort parameter in company directory and well…this works perfectly! therefore i am a lil bit confused. whats wrong here?
thanks

edit: seems that it just orders by product_name instead of custom field
Last edited by nicmare on Mon May 10, 2010 3:03 pm, edited 1 time in total.
nicmare
Power Poster
Power Poster
Posts: 1150
Joined: Sat Aug 25, 2007 9:55 am

Re: [Products] Sorting by field definitions does not work

Post by nicmare »

i tried to spot both functions:

in company directory:

Code: Select all

if( startswith($str,'f:') )
	  {
	    $fielddefs = $this->GetFieldDefs();
	    $tmp = substr($str,2);
	    for( $i = 0; $i < count($fielddefs); $i++ )
	      {
		if( $fielddefs[$i]->name == $tmp )
		  {
		    $sort_fielddef = clone $fielddefs[$i];
		  }
	      }
	  }

in products:

Code: Select all

if( startswith($tmp,'f:') )
	  {
	    $fieldname = substr($tmp,strlen('f:'));
	    if( isset($fielddefs[$fieldname]) )
	      {
		$fieldid = $fielddefs[$fieldname]->id;
		$as = 'FV'.$sortfield++;
		$joins[] = cms_db_prefix()."module_products_fieldvals {$as} ON c.id = {$as}.product_id AND $as.fielddef_id = '{$fieldid}'";
		$sortby = "{$as}.value";
	      }
	  }
but dont know how do modify it :(
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: [Products] Sorting by field definitions does not work

Post by calguy1000 »

Okay, I have now spent 2 hours (one hour each) on separate occasions setting up for, and testing Products for exactly this functionality. Once just now, and another time when I received an email from a bug report. And both times I have had no problems.

I went so far as to output debugging information in the output, and checking absolutely everything.  IT WORKS!!!

Attached is a screenshot of the result of calling {Products sortby='f:rating} which is a dropdown field with values from 1 to 5.
I suggest you export your products to ASCII and look at the values it outputs, this should give you a hint as to what the problem is.
Attachments
snapshot12.jpg
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
nicmare
Power Poster
Power Poster
Posts: 1150
Joined: Sat Aug 25, 2007 9:55 am

Re: [Products] Sorting by field definitions does not work

Post by nicmare »

really strange!
i use products this way:

Code: Select all

{Products category="Golffilme" summarytemplate="Golffilme" sortby="f:Reihenfolge"}
(german names, don't wonder)
And this makes the same order like product_name (default).
here is my screenshot of the frontend where testvar is field Reihenfolge (rating):
Attachments
Bildschirmfoto-2010-05-12-um-10.19.37.jpg
tpsvca
Forum Members
Forum Members
Posts: 14
Joined: Mon Feb 08, 2010 8:22 am

Re: [Products] Sorting by field definitions does not work

Post by tpsvca »

Hello there,

i have problem even stranger then this one...
In the same site:
{Products category="cat1" summarytemplate="transport" sortby="f:sorting"} works
{Products category="cat3" summarytemplate="transport" sortby="f:sorting"} works
{Products category="cat4" summarytemplate="transport" sortby="f:sorting"} works

{Products category="cat2" summarytemplate="career" sortby="f:sorting"} didn't work

.......
Have cleared cache - nothing, testing in different ways nothing can help...
Pedgey88
New Member
New Member
Posts: 4
Joined: Sun May 22, 2011 2:50 pm

Re: [Products] Sorting by field definitions does not work

Post by Pedgey88 »

I have the same problem. Whenever I try to add a custom sort, it keeps sorting on product name.

I imported all my products trough CSV import. Could this cause the problem?
tpsvca
Forum Members
Forum Members
Posts: 14
Joined: Mon Feb 08, 2010 8:22 am

Re: [Products] Sorting by field definitions does not work

Post by tpsvca »

I have solved my problem...
Looks like problem becomes when you editing existing {Products} tag. Try to delete {Product} tag, save your page, and then enter new and full (with all options) {products} tag.
After that modify every field in your products, you need to sort and save products.

I think this is the problem with cashing.... And a little bit annoying :)
Pedgey88
New Member
New Member
Posts: 4
Joined: Sun May 22, 2011 2:50 pm

Re: [Products] Sorting by field definitions does not work

Post by Pedgey88 »

Is there another way to re-save every product? I have the same issue but have ~800 products. I would lose to much time opening every product and resaving it.
tpsvca
Forum Members
Forum Members
Posts: 14
Joined: Mon Feb 08, 2010 8:22 am

Re: [Products] Sorting by field definitions does not work

Post by tpsvca »

Try to switch of cache and delete everything in cache directory (this trick didn't help for me...)
Pedgey88
New Member
New Member
Posts: 4
Joined: Sun May 22, 2011 2:50 pm

Re: [Products] Sorting by field definitions does not work

Post by Pedgey88 »

tpsvca wrote:Try to switch of cache and delete everything in cache directory (this trick didn't help for me...)
That was the first thing I tried but no luck
Post Reply

Return to “Modules/Add-Ons”