Author Topic: Parameter search (dropdown)  (Read 69171 times)

Cajetan

  • Beginner
  • *
  • Posts: 16
Parameter search (dropdown)
« on: December 01, 2008, 22:56:05 pm »
Hello there, after reading these forums for years and using VM for a long time as well I'd like to give something back to the community. Hope I hit the right subforum. I attached a screenshot.

Features, simple as they are:
# Shows the parameters of a certain product-type as dropdownboxes, so you can filter your search with them.

-------------------------------------------
Current version: 0.7 (12/5/2008)
Updates:
- Now it is possible to exclude certain parameters within backend module configuration
version: 0.6
Updates:
- Added checkboxes for the display of introduction,name-search, price-search (Thanks korb!)
- Labels can be formatted with hex-colors (#000000) via administration
- The Labels of price-search and name-search are fetched from virtuemart itself
- The search-button now has a default value ('Search') (Thanks korb!)
- You can choose a product type from backend now

You'll find the download below
-------------------------------------------

Please note: I'm a super-scrub concerning programming and although I found out it works for me, it still requires some manual work in order to fit it to individual needs. I'm planning improvement on usability and flexibility though.

Any help, suggestions and hints are very very welcome!
Things that need to be solved:
#1 array-error when there are multi-select parameters
#2 Implementation of ajax


I'm not sure whether I stated everything correctly in the copyright as the little hacking I have done is based on the already existing parameter search built into VM ... Don't want to receive a ban for copyright infringements :) If there's a problem occuring please notify me!

Note for use: I limited the display of boxes according to parameter_type "V" as I got a ton more parameters than I want to show in the module[/u]. Thus selecting it via parameter_type. If more explanations are needed I hope I can deliver them. Additionally I used inline styles for CSS, god forgive me, I think it's better everybody uses his own IDs/classes and inserts them himself  :)

EDIT: Removed the Code for reading convenience.

Thanks in advance & have fun trying!

EDIT: My english got really really rusty, I think I need to participate a lot more ;)

Regards,
Cajetan

[attachment cleanup by admin]
J! 1.5.8 & VM 1.1.2

korb

  • Quality&Testing Team
  • Full Member
  • *
  • Posts: 685
  • VM 2.0 in heavy testing
    • Buy my work
Re: Virtuemart+Joomla Module: Parameter search (dropdown)
« Reply #1 on: December 04, 2008, 17:56:33 pm »
Hey I was just about t write a FRQ for making such a thing.

BUGS LIST - things we must settle first
Ok, I installed your module, but it does not show all parameters and I need to make it work for all my product types (6 so far). So first we need to eliminate the parameter type delimiter.
SO to do that, go to line 40 and delete
Code: [Select]
AND parameter_type='V'
The seccond problem is that "Search" string of that search button does not appear.

Third issue: what is product name field for? like a keyword? We need to know how to remove this just in case. Maybe a config in the module administration.

Fourth issue is not automatically detecting product_type_id, so we need to construct a query where we join tables (temporarly and locally merging) #_vm_product_product_type_xref and #_vm_product_category_xref in such a manner it will understand the relation between category_id and product_type_id, and we could get product_type_id for each category AUTOMATICALLY.

Last BIGEST ISSUE: if you have SEF on (like sh404SEF), and we have a multipage search results page, pagination does not work, I've seen some sites using VM with a href="../20-inch" where 20 inch is a parameter value, and this is placed in the link instead of "../product_type_id=1&product_type_diagonal_s=20%inch" so we desperately need a function to encode these variables that are shown in the links.

FRQ LIST - how to make this be the best filter ever seen.
1. we need a general filter that include these all:
-filter by manufacturer,
-filter by product types parameters (our case here),
-filter by stock (checkbox to show only products in stock or create a dropdown box with in stock/out of stock/all),
-filter by commented products (checkbox to show only products with at least one comment)
-filter by sales (checkbox to show only products with product_sales > 0)

2. we must have a backend option to exclude price as a parameter for the search.

3. if someone wants to use price let's make it use price intervals. This means the code inside will calculate 5 price intervals based to the prices of the category so we could have products classified as:
-low cost (price interval 1)
-medium-low cost (price interval 2)
-medium (price interval 3)
-premium (price interval 4)
-super premium (price interval 5).

I am no coder but I read a lot of ecommerce and ebusiness, and I can tell this is how to make VirtueMart the best open source shopping cart.

Those who are interested in this development, please subscribe (Notify) to the topic and donate to pay a developer to code it.

Get back with news.
Danny

Cajetan

  • Beginner
  • *
  • Posts: 16
Re: Virtuemart+Joomla Module: Parameter search (dropdown)
« Reply #2 on: December 04, 2008, 20:19:15 pm »

Ok, I installed your module, but it does not show all parameters and I need to make it work for all my product types (6 so far). So first we need to eliminate the parameter type delimiter. SO to do that, go to line 40 and delete
Code: [Select]
AND parameter_type='V'

I'm working on this one, in my local version I've got a dropdown-menu in the backend displaying all available product types - but you can only choose one product type (and its parameters)

The limit you mentioned above is a means to prevent certain parameters from being shown; One might have 10 Parameters but only wants to show 4 of them.

Right now I have no clue how to solve that issue :(
EDIT: Thinking of checkboxes for backend again, showing all available parameters, and the admin would be able to choose the wanted ones.

Quote from: korb
The seccond problem is that "Search" string of that search button does not appear.
I'm very new to module creating, will check out default values for params
Edit: Default label now is "Search"

Quote from: korb
Third issue: what is product name field for? like a keyword? We need to know how to remove this just in case. Maybe a config in the module administration.
Indeed, it is. Maybe a checkbox in the backend would be a lot more convenient in case you want to turn it on/off?

Quote from: korb
Fourth issue is not automatically detecting product_type_id, so we need to construct a query where we join tables (temporarly and locally merging) #_vm_product_product_type_xref and #_vm_product_category_xref in such a manner it will understand the relation between category_id and product_type_id, and we could get product_type_id for each category AUTOMATICALLY.
That's a big one =)

Quote from: korb
Last BIGEST ISSUE: if you have SEF on (like sh404SEF), and we have a multipage search results page, pagination does not work, I've seen some sites using VM with a href="../20-inch" where 20 inch is a parameter value, and this is placed in the link instead of "../product_type_id=1&product_type_diagonal_s=20%inch" so we desperately need a function to encode these variables that are shown in the links.

Is this an issue for the module? Thought the search-engine is creating the URL for those.

Quote from: korb
FRQ LIST - how to make this be the best filter ever seen.
1. we need a general filter that include these all:
-filter by manufacturer,
-filter by product types parameters (our case here),
-filter by stock (checkbox to show only products in stock or create a dropdown box with in stock/out of stock/all),
-filter by commented products (checkbox to show only products with at least one comment)
-filter by sales (checkbox to show only products with product_sales > 0)
2. we must have a backend option to exclude price as a parameter for the search.
3. if someone wants to use price let's make it use price intervals. This means the code inside will calculate 5 price intervals based to the prices of the category so we could have products classified as:
-low cost (price interval 1)
-medium-low cost (price interval 2)
-medium (price interval 3)
-premium (price interval 4)
-super premium (price interval 5).

I am no coder but I read a lot of ecommerce and ebusiness, and I can tell this is how to make VirtueMart the best open source shopping cart.
Those who are interested in this development, please subscribe (Notify) to the topic and donate to pay a developer to code it.
Get back with news.
Danny

Thank you very much for your input :) Lots of cool ideas in your feature-list as well, especially the 3rd one, using price intervals (bold). I'd be very glad if this turned into a teamwork-thread as my coding-knowledge is limited.

Regards,
Cajetan
J! 1.5.8 & VM 1.1.2

korb

  • Quality&Testing Team
  • Full Member
  • *
  • Posts: 685
  • VM 2.0 in heavy testing
    • Buy my work
Re: Filter Module: Parameter search (dropdown)
« Reply #3 on: December 04, 2008, 21:01:25 pm »
Thanks for feedback, I waited a long time for a partner to do this. We realy need this, because VM is very lost in time, so we need to bring it back to life.

Cajetan

  • Beginner
  • *
  • Posts: 16
Re: Filter Module: Parameter search (dropdown)
« Reply #4 on: December 04, 2008, 22:26:22 pm »
I updated the version to 0.6, there are some changes, most are dealing with usability issues. Code's not clean yet :)

- Added checkboxes for the display of introduction,name-search, price-search (Thanks korb!)
- Labels can be formatted with hex-colors (#000000) via administration
- The Labels of price-search and name-search are fetched from virtuemart itself
- The search-button now has a default value ('Search') (Thanks korb!)
- You can choose a product type from backend now
- The limit of the module only showing parameters with multiple values ('V' in the databank) has been removed (effectively showing ALL parameters from the product type)

You can get the file from the opening post.

Concerning the idea to ensure people can check the parameters they want to display: with current un-hacked joomla versions it's not possible to create multi-select lists or to display SQL-Queries in another way (e.g. text-boxes) than in a regular dropdown-box. Thus the user won't get any feedback on the parameters in a product type.

But, one could enter the parameters he wants to use in a textbox... The problem is: This system relies on the user correctly entering everything correctly.

The file is back online

Regards,
Cajetan
J! 1.5.8 & VM 1.1.2

Cajetan

  • Beginner
  • *
  • Posts: 16
Re: Filter Module: Parameter search (dropdown)
« Reply #5 on: December 05, 2008, 00:29:10 am »
Hope there's no problem with doubleposting policy when I write about the next released version ...

Well, version 0.7 is now available for download, together with the option to exclude certain parameters from display on frontend.

Please use this example, as at the moment the formatting needs to be followed strictly:
Code: [Select]
'Parameter1', 'Parameter5', 'Parameter7', ...
In fact you should be able to exclude as many parameters as you want.

Regards,
Cajetan
J! 1.5.8 & VM 1.1.2

Han Leentvaar

  • Beginner
  • *
  • Posts: 3
Re: Filter Module: Parameter search (dropdown)
« Reply #6 on: December 05, 2008, 02:05:37 am »
Hi, for V.07:
When price search is disabled, the search button is also disabled.
Corrected code begins line 87:
Code: [Select]
   else {
    echo "<div>";
    echo "<label style='font-weight:bold;color:". $label_color ."'>". $VM_LANG->_('PHPSHOP_CART_PRICE') ."</label><br />";
    $item_name = "price";
  $get_item_value = vmGet($_REQUEST, $item_name, "");
  $get_item_value_comp = vmGet($_REQUEST, $item_name."_comp", "");
  echo "<select class=\"inputbox\" name=\"price_comp\">";
  echo "<option value=\"lt\"".(($get_item_value_comp=="lt")?" selected":"").">&lt;</option>\n";
  echo "<option value=\"le\"".((empty($get_item_value_comp)||$get_item_value_comp=="le")?" selected":"").">&lt;=</option>\n";
  echo "<option value=\"eq\"".(($get_item_value_comp=="eq")?" selected":"").">=</option>\n";
  echo "<option value=\"ge\"".(($get_item_value_comp=="ge")?" selected":"").">&gt;=</option>\n";
  echo "<option value=\"gt\"".(($get_item_value_comp=="gt")?" selected":"").">&gt;</option>\n";
  echo "<option value=\"ne\"".(($get_item_value_comp=="ne")?" selected":"").">&lt;&gt;</option>\n";
  echo "</select> ";
  echo "<input type=\"text\" class=\"inputbox\"  name=\"price\" value=\"$get_item_value\" size=\"20\" />\n";
  echo "</div>";
}
   echo "<div>";
   echo "<div align='center'><br /><input type='submit' class='button' name='search' value='". $button_label."'></div>";
   echo "</div>";
   ?>

I myself am still looking to the problem that I get an error (3 times):
Warning: Invalid argument supplied for foreach() in /home/klavar/domains/klavarskribo.nl/public_html/administrator/components/com_virtuemart/classes/ps_product_type.php on line 459


When I observe these lines (457) in ps_product_type.php:
Code: [Select]
if ($db->f("parameter_multiselect")=="Y" && $db->f("parameter_values")) { // Multiple section List of values
$get_item_value = vmGet($_REQUEST, $item_name, array());
I see a difference when I use the dropdown search and the original product type search.
The dropdown gives
Item name: product_type_1_handschrift
Item value: Ja

While the official one gives:
Item name: product_type_1_handschrift
Item value: Array


Seems not correct... The official one shows an array...

Regards, Han (Joomla 1.5.8, VM 1.1.2)

korb

  • Quality&Testing Team
  • Full Member
  • *
  • Posts: 685
  • VM 2.0 in heavy testing
    • Buy my work
Re: Filter Module: Parameter search (dropdown)
« Reply #7 on: December 05, 2008, 03:45:27 am »
OK back with news:

First this is not a filter yet, it is Advaced Search Accordiong to Parameters, because a filter does not need search button, and when you select a parameter value, the search is automatically started.

Then the main concern is autodetect product type id for each category.

Then the URL and route. The filter does not have to redirect to index.php like VM parameter search does. It should only add
Code: [Select]
&parameter_value, like
Code: [Select]
&1000MHz to the link and not redirect to index.php, so in this case pagination is normal like it supose to be and the variables
Code: [Select]
product_type_parameter=value ofcourse MUST NOT APPEAR IN THE LINK. I will soon attach a GUI (graphical user interface) with some explinations inside.

The other features mentioned by me are easy implementations, most important is what I stated this post.
Danny

Cajetan

  • Beginner
  • *
  • Posts: 16
Re: Parameter search (dropdown)
« Reply #8 on: December 05, 2008, 14:12:20 pm »
Quote from: Han Leentvaar
When price search is disabled, the search button is also disabled.

Thanks a lot for pointing this one out, Han!

Quote from: Han Leentvaar
I myself am still looking to the problem that I get an error (3 times):
Warning: Invalid argument supplied for foreach() in /home/klavar/domains/klavarskribo.nl/public_html/administrator/components/com_virtuemart/classes/ps_product_type.php on line 459

But the output seems to work ??? I'll try to fix it asap!

Quote from: korb
First this is not a filter yet, it is Advaced Search Accordiong to Parameters, because a filter does not need search button, and when you select a parameter value, the search is automatically started.

While I think certain filters (like # of displayed products in browse page) do not need a "Filter"/"Search"-button, I believe it'll be better to keep the button  just in case someone wants to select multiple parameters (I can only imagine the search being triggered by the selection of ONE field, which would effectively exclude the other parameters).

Quote from: korb
Then the URL and route. The filter does not have to redirect to index.php like VM parameter search does. It should only add &parameter_value, like &1000MHz to the link and not redirect to index.php, so in this case pagination is normal like it supose to be and the variables product_type_parameter=value ofcourse MUST NOT APPEAR IN THE LINK. I will soon attach a GUI (graphical user interface) with some explinations inside.

As I'm no coder either, I'm just experimenting :) There's an addition to the form-action I'm trying:

Search for this line (line 55 in 0.7):
Code: [Select]
<form action="<?php echo URL ?>index.php" method="post" name="attr_search">

Behind index.php add the following:
Code: [Select]
?option=com_virtuemart&page=shop.browse
Please note
- The entry of your current page in breadcrumbs-module does not yield any value!
- This is just a "cosmetic" change! Pagination should start when you have at least 5 products matching the parameters you chose


Concerning the connection of categories and the parameter search: There is a way to get the needed values from the tables you mentioned, no problem. But how would you assign parameter search to categories? However, the possibility exists to connect different parameter searches to single products. Is it that what you're talking about?

Thanks a lot for your feedback you two, I really appreciate it!

Regards,
Cajetan
J! 1.5.8 & VM 1.1.2

korb

  • Quality&Testing Team
  • Full Member
  • *
  • Posts: 685
  • VM 2.0 in heavy testing
    • Buy my work
Re: Parameter search (dropdown)
« Reply #9 on: December 05, 2008, 15:53:18 pm »
In our form we really need to add manufacturer_id and category_id, and with the help of experienced developers, we could try to do what I posted the second post this topic.
This must be and work as a filter and not as the old and buggy parameter search.
Danny

korb

  • Quality&Testing Team
  • Full Member
  • *
  • Posts: 685
  • VM 2.0 in heavy testing
    • Buy my work
Re: Parameter search (dropdown)
« Reply #10 on: December 06, 2008, 18:06:13 pm »
NO one else interested in this development?

Cajetan

  • Beginner
  • *
  • Posts: 16
Re: Parameter search (dropdown)
« Reply #11 on: December 07, 2008, 16:07:42 pm »
Well, I'm still interested and still working on the module :)

Regards,
Cajetan
J! 1.5.8 & VM 1.1.2

korb

  • Quality&Testing Team
  • Full Member
  • *
  • Posts: 685
  • VM 2.0 in heavy testing
    • Buy my work
Re: Parameter search (dropdown)
« Reply #12 on: December 07, 2008, 23:23:02 pm »
What is the status, the next phase of the development?

Cajetan

  • Beginner
  • *
  • Posts: 16
Re: Parameter search (dropdown)
« Reply #13 on: December 07, 2008, 23:36:16 pm »
#1 Trying to fix the error reported by Han
#2 Implementing Ajax

Both are not that easy, but Ajax runs at least (under certain circumstances; those  being: a special component needs to be installed  :( ) Together with another member of this forum I thought about this whole category-connectedness and we decided it'd be too complicated as well because you'd need additional fields/an additional table within the database. Plus you need to assign every category to a certain module in the backend (with the aforementioned database-changes).

#1 works correctly in case you don't have any MULTISELECT Parameters :) Still trying to figure out how to handle the needed arrays :(

Regards,
Cajetan
J! 1.5.8 & VM 1.1.2

avra911

  • Beginner
  • *
  • Posts: 9
Re: Parameter search (dropdown)
« Reply #14 on: December 30, 2008, 13:31:43 pm »
Multiple select problem in parameter search should be solved in the VM1.1.2 core as a must.

this should be an important update to the next release.

check this
http://forum.virtuemart.net/index.php?topic=48719.msg160053#msg160053
it seems to work fine for me