Skip to main content

Adding price filters - during import

More
9 years 5 months ago - 9 years 5 months ago #3405 by redactie
An effective method of getting fixed price ranges is to calculate the correct range during the import of the datafeeds and assign the string to one of the select field. In the example below number 12.

Now you can use the value in your menu or as sort option







This should work in all version of the component
Code:
#add to your callback filter, below the generic_cb($item); $p=(float)$item['prijs']; switch ( true ) { case ($p < 10) : $item['menu_12']='Tot 10€';break; case ($p < 25) : $item['menu_12']='Tot 25€';break; case ($p < 100) : $item['menu_12']='Tot 100€';break; default : $item['menu_12']='Meer dan 100€'; }

issue

The menu is sorted by alphabet, I'm working on that one, First step is to alter the type of the used database field ( in this case Select12 ) into an enum:
Code:
ALTER TABLE `XXX_dataitems` CHANGE `Select12` `Select12` ENUM( 'Tot 10€', 'Tot 25€', 'Tot 100€', 'Meer dan 100€' ) NOT NULL ;

but there is still a sort issue in the component.

workaround

ensure the strings are sortable by alphabet in the correct order:
Code:
@$p=(float)$item['prijs']; switch ( true ) { case ($p< 10) : $item['menu_12']='Tot 10€';break; case ($p< 25) : $item['menu_12']='Van 10 tot 25€';break; case ($p< 50) : $item['menu_12']='Van 25 tot 50€';break; case ($p< 100) : $item['menu_12']='Van 50 tot 100€';break; default : $item['menu_12']='Vanaf 100€'; }
Attachments:
Last edit: 9 years 5 months ago by redactie.

Please Log in to join the conversation.

More
9 years 4 months ago #3449 by bassie
Thank you Bram,

Is the sorting date issue fixed ?
I mean the menu on my website will be sorted like:
Attachments:

Please Log in to join the conversation.

More
9 years 4 months ago #3452 by redactie
I have some solution, but not sure whether or not to keep it.

workarond is for now to have creative strings.

Tot 10
van 10 to 25
van 25 tot 50
....
vanaf 100 tot 150
...
vanaf 750

Please Log in to join the conversation.

Time to create page: 0.428 seconds