Page 1 of 1
[Products] Sorting by field definitions does not work
Posted: Mon May 10, 2010 12:04 pm
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
Re: [Products] Sorting by field definitions does not work
Posted: Tue May 11, 2010 9:41 pm
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

Re: [Products] Sorting by field definitions does not work
Posted: Tue May 11, 2010 10:15 pm
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.
Re: [Products] Sorting by field definitions does not work
Posted: Wed May 12, 2010 8:21 am
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):
Re: [Products] Sorting by field definitions does not work
Posted: Mon Jun 13, 2011 5:48 am
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...
Re: [Products] Sorting by field definitions does not work
Posted: Mon Jun 13, 2011 6:35 am
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?
Re: [Products] Sorting by field definitions does not work
Posted: Mon Jun 13, 2011 9:50 am
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

Re: [Products] Sorting by field definitions does not work
Posted: Mon Jun 13, 2011 4:20 pm
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.
Re: [Products] Sorting by field definitions does not work
Posted: Tue Jun 14, 2011 5:24 am
by tpsvca
Try to switch of cache and delete everything in cache directory (this trick didn't help for me...)
Re: [Products] Sorting by field definitions does not work
Posted: Tue Jun 14, 2011 5:35 pm
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