Jump to content



Issue Information

  • #000630

  • 0 - None Assigned

  • Won't Fix

  • 2.3.3.2

  • -

Issue Confirmations

  • Yes (3)No (0)
Photo

Advanced Search on just category and/or manufacturer results in error

Posted by wdepot on 18 September 2013 - 22:50

I just realized that Advanced Search posts an error message when it should not. If a category name (i.e. not All Categories) and/or a manufacturer name (i.e. not All Manufacturers) is selected without entering any other information into the form then the search is actually valid but the file gives an error message that a search term is required. The form should be testing the current values of these two fields as well as the other fields. If either Category or Manufacturer has been selected then a search should be performed regardless of whether any of the other fields has been filled out or not.

I just realized that Advanced Search posts an error message when it should not. If a category name (i.e. not All Categories) and/or a manufacturer name (i.e. not All Manufacturers) is selected without entering any other information into the form then the search is actually valid but the file gives an error message that a search term is required. The form should be testing the current values of these two fields as well as the other fields. If either Category or Manufacturer has been selected then a search should be performed regardless of whether any of the other fields has been filled out or not.



I tried this and get the same results as @wdepot and I agree with the point being made. Customer wants to see all flat screens by Sony....sure that type of search is very possible.

http://demo.oscommer...to=&dfrom=&dto=

searching for the letter "g" returning only products from Matrox.

If you enter no search term, that will result in an error.

The search is a search system, not a filtering system.

Mind you, I see value in changing it, so why not come up with the code @wdepot and I will add it in my github.

Edited by burt, 19 September 2013 - 12:30.


Change should be pretty simple. In advanced_search_results.php change:
  if ( (isset($HTTP_GET_VARS['keywords']) && empty($HTTP_GET_VARS['keywords'])) &&
	   (isset($HTTP_GET_VARS['dfrom']) && (empty($HTTP_GET_VARS['dfrom']) || ($HTTP_GET_VARS['dfrom'] == DOB_FORMAT_STRING))) &&
	   (isset($HTTP_GET_VARS['dto']) && (empty($HTTP_GET_VARS['dto']) || ($HTTP_GET_VARS['dto'] == DOB_FORMAT_STRING))) &&
	   (isset($HTTP_GET_VARS['pfrom']) && !is_numeric($HTTP_GET_VARS['pfrom'])) &&
	   (isset($HTTP_GET_VARS['pto']) && !is_numeric($HTTP_GET_VARS['pto'])) ) {
    $error = true;
    $messageStack->add_session('search', ERROR_AT_LEAST_ONE_INPUT);
  } else {

to:
  if ( (isset($HTTP_GET_VARS['keywords']) && empty($HTTP_GET_VARS['keywords'])) &&
	   (isset($HTTP_GET_VARS['dfrom']) && (empty($HTTP_GET_VARS['dfrom']) || ($HTTP_GET_VARS['dfrom'] == DOB_FORMAT_STRING))) &&
	   (isset($HTTP_GET_VARS['dto']) && (empty($HTTP_GET_VARS['dto']) || ($HTTP_GET_VARS['dto'] == DOB_FORMAT_STRING))) &&
	   (isset($HTTP_GET_VARS['pfrom']) && !is_numeric($HTTP_GET_VARS['pfrom'])) &&
	   (isset($HTTP_GET_VARS['pto']) && !is_numeric($HTTP_GET_VARS['pto'])) &&
	   (isset($HTTP_GET_VARS['manufacturers_id']) && !is_numeric($HTTP_GET_VARS['manufacturers_id'])) &&
	   (isset($HTTP_GET_VARS['categories_id']) && !is_numeric($HTTP_GET_VARS['categories_id']))) {
    $error = true;
    $messageStack->add_session('search', ERROR_AT_LEAST_ONE_INPUT);
  } else {

Then change the line that reads:
  if (empty($dfrom) && empty($dto) && empty($pfrom) && empty($pto) && empty($keywords)) {
    $error = true;
    $messageStack->add_session('search', ERROR_AT_LEAST_ONE_INPUT);
  }

To:
  if (empty($dfrom) && empty($dto) && empty($pfrom) && empty($pto) && empty($keywords) && empty($HTTP_GET_VARS['manufacturers_id']) && empty($HTTP_GET_VARS['categories_id'])) {
    $error = true;
    $messageStack->add_session('search', ERROR_AT_LEAST_ONE_INPUT);
  }

Then in the javascript at the beginning of advanced_search.php add the following to the list of vars:
  var cat_id = document.advanced_search.categories_id.value;
  var mfg_id = document.advanced_search.manufacturers_id.value;

And change the check that reads like this:
  if ( ((keywords == '') || (keywords.length < 1)) && ((dfrom == '') || (dfrom.length < 1)) && ((dto == '') || (dto.length < 1)) && ((pfrom == '') || (pfrom.length < 1)) && ((pto == '') || (pto.length < 1)) ) {
    error_message = error_message + "* <?php echo ERROR_AT_LEAST_ONE_INPUT; ?>\n";
    error_field = document.advanced_search.keywords;
    error_found = true;
  }

to read like this instead:
  if ( ((keywords == '') || (keywords.length < 1)) && ((dfrom == '') || (dfrom.length < 1)) && ((dto == '') || (dto.length < 1)) && ((pfrom == '') || (pfrom.length < 1)) && ((pto == '') || (pto.length < 1)) && (cat_id == '') && (mfg_id == '')) {
    error_message = error_message + "* <?php echo ERROR_AT_LEAST_ONE_INPUT; ?>\n";
    error_field = document.advanced_search.keywords;
    error_found = true;
  }


Installed and testing on a 2.3.3.4 shop. Working well. Did a repo if anyone finds this and wants to view the changes that way.
https://github.com/s...d-search-update

As a suggestion, when in advanced search, after selected either the category or manufacturer you want, it would be user friendly if the first drop down selected would filter out the search possibilities in the other. Example, you select cars in the category but you don't currently have any Ford mfg cars in stock so the customer would not see/get Ford as a manufacturer option in that drop down.

Thanks Kevin, I think this enhances the user experience when doing an advanced search.

wDepot, good script however try selecting all categories with a specific manufacturer. I receive the correct text ( results display 1 of 3) but no products are displayed. /sad.png' class='bbc_emoticon' alt=':(' /> only a back button.


Thanks.

Attached Thumbnails

  • defect1.GIF
  • defect1_noproductimage.GIF


Sorry, INFLICT, I am unable to duplicate your results. When I try advanced search on just a manufacturer after making the changes I posted earlier I get a list of products as expected. I don't know if the information you posted in the pictures would have revealed the problem or not, they were too small to read and refused to enlarge.

Thanks for the help and so I went to github and re uploaded the script and I still have the same issue. If I search for only a Manufacturer the product images don't display (again I do see that is says 1 to 4 producst out of 4 ). I only see the text about how many products should be shown.

Do you have any ideas on how I can go about fixing this? BTW if I search only for categories, the advanced search works fine. Do you know what page would be responsible for showing the images? Maybe another add on causing issues for me?


Wdepot the issue is that when I select "all categories" and then any one manufacturer that has products associated with them. I only get text with no images, so for instance. If I search for manufacturer "canon" I get the following.

Displaying 1 to 2 (of 2 products) Result Pages: 1

But there is no image of the two products. Can you point me in the right direction?

Okay so with some help from Jim, I was able to figure out what the issue is (I still need to fix it though /sad.png' class='bbc_emoticon' alt=':(' /> ). the issue is the file includes/modules/product_listing.php. I modified that page for display purposes and must have either modified, deleted, or otherwise modified the file causing the issue listed for me. So no issues with the script at all but remember which page is generating the products on the advanced search are coming from product_listing.php I hope this may help someone else, thanks. (Thanks wdepot and everyone else that looked at this issue and helped)

changed status to: Won't Fix

Start a new thread in the forum and tag those users who posted here to come and get involved in your new thread.

Bug that is not a bug is now closed.