Dear all,
My question has to do with the product attributes in the Products module.
I'm using the products module as a reservation system for seminars.
The "main" product is ie. "Teamleiderdag"
As attributes I set the dates. (ie. 1 september 2010 and 4 december 2010).
The problem I'm facing now is that the order of the attributes change to a random order, although I set them in the right order when adding the attributes. When I save the changes in admin and check the attributes back, the order has changed.
For an example, see:
http://www.teamleiderin100dagen.nl/even ... -seminars/
Is there a way to set the attributes in a certain order? I tried adjusting the SKU of the attributes to see if that was the solution but no luck.
Any help would be greatly appreciated. :)
Regards,
Jeroen,.
CMSMS 1.7.1
CGExtensions 1.18.7
CGSimpleSmarty 1.4.4
CGEcommerceBase 1.1.1
Products 2.8.2
Products attributes order
-
- Forum Members
- Posts: 46
- Joined: Sat Mar 06, 2010 10:38 am
Products attributes order
Last edited by GroeneKaktus on Wed Jul 21, 2010 12:01 pm, edited 1 time in total.
Re: Products attributes order
hi there, i have the same problem
any solution yet ?
kind regards,
Peter
any solution yet ?
kind regards,
Peter
Re: Products attributes order
From what I see on my site, in don't get how it is sorted in list of attributes. But, at least on my page, In the dropdown, where you select atributtes for adding to cart, it sorts alphabetically. So for that, might help to add prefix for names of variables like: first date, second date, etc.
For the text listing, there might bw another solution. that is simply don't use products variable to do the listing, but make it for your own. Here is my UDT, which will return array of attrib values and names, sorted like in dropdown-menu.:
let's call it strip_attribcontrol
Then, on your Products page template, you call it with:
{strip_attribcontrol input=$attributes[0]->control}
and after that, you should get variable {$select_options}, which is array, where key is attrib vaule (for dropdown menus and so on) and value is attrib name.
So, for example, in your template, you can use:
{foreach from=$select_options key=value item=name}
{$name}
{/foreach}
And you should get attribs, in same order as in dropdown-menu (alphabetically sorted, I hope)
If you are little more skilled with php, you can alter the UDT, that it will sort the array really by the dates...
Note:
I made this UDT for cusomizing attrib-select dropdown menu, so there are also vars {$select_start} and {$select_end}, and it's primary function is, that you can make dropdown with this:
{$select_start}
{foreach from=$select_options key=value item=name}
{$name}
{/foreach}
{$select_end}
and thanks to that, you can customize dropdown much more, than cart in default offers... You can also make radio buttons instead of dropdown as well... But it might help you also with the sorting problem...
For the text listing, there might bw another solution. that is simply don't use products variable to do the listing, but make it for your own. Here is my UDT, which will return array of attrib values and names, sorted like in dropdown-menu.:
Code: Select all
$input = $params['input'];
$first_opt_pos = stripos($input,"<option value=");
$select_start = substr($input,0,$first_opt_pos);
$select_end = "</select>";
$options = substr($input,$first_opt_pos);
$options = substr($options,0,-strlen($select_end)-1);
$options_count = substr_count($options,"<option");
$select_options = array();
for($i = 1; $i <= $options_count; $i++) {
$u_pos = stripos($options, "\"");
$options = substr($options, $u_pos + 1);
$u_pos = stripos($options, "\"");
$select_value = substr($options, 0, $u_pos);
$u_pos = stripos($options, ">");
$options = substr($options, $u_pos + 1);
$u_pos = stripos($options, "<");
$select_name = substr($options, 0, $u_pos);
$u_pos = stripos($options, ">");
$options = substr($options, $u_pos + 1);
$select_options[$select_value] = $select_name;
};
$smarty->assign('select_start',$select_start);
$smarty->assign('select_end',$select_end);
$smarty->assign('select_options',$select_options);
Then, on your Products page template, you call it with:
{strip_attribcontrol input=$attributes[0]->control}
and after that, you should get variable {$select_options}, which is array, where key is attrib vaule (for dropdown menus and so on) and value is attrib name.
So, for example, in your template, you can use:
{foreach from=$select_options key=value item=name}
{$name}
{/foreach}
And you should get attribs, in same order as in dropdown-menu (alphabetically sorted, I hope)
If you are little more skilled with php, you can alter the UDT, that it will sort the array really by the dates...
Note:
I made this UDT for cusomizing attrib-select dropdown menu, so there are also vars {$select_start} and {$select_end}, and it's primary function is, that you can make dropdown with this:
{$select_start}
{foreach from=$select_options key=value item=name}
{$name}
{/foreach}
{$select_end}
and thanks to that, you can customize dropdown much more, than cart in default offers... You can also make radio buttons instead of dropdown as well... But it might help you also with the sorting problem...