Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

Expand fields in Admin search


4 replies to this topic

#1 mugitty

  • Community Member
  • 1,201 posts
  • Real Name:Stuart Owens
  • Location:Great Southeastern Washington Desert, USA

Posted 15 March 2003, 09:28

I asked this earlier but I'll try to be a little more specific with what I'm trying to accomplish.

It appears that when you search in the Admin area within the Category/Product area, that the search only keys on the product name or the category name, i.e. I search for "engine" and the return includes all folders with "engine" in their name and all individual products with "engine" in their name. I would like to expand this function so that if I enter a product_model number, I can also get a return that way. As it stands now, if I enter the model, I get no return.

It seems that the area of categories.php that would control this is here:
<?php

    }



    $products_count = 0;

    if ($HTTP_GET_VARS['search']) {

     $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_bimage, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_model, p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and p.products_id = p2c.products_id and pd.products_name like '%" . $HTTP_GET_VARS['search'] . "%' order by p.products_model");

    } else {

      $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_bimage, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_model from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = '" . $current_category_id . "' order by p.products_model");

    }

    while ($products = tep_db_fetch_array($products_query)) {

      $products_count++;

      $rows++;
Can anyone help with how to amend this so I can get a return on product_model in addition to the currently returned results?

Thanx :)
... if you want to REALLY see something that doesn't set up right out of the box without some tweaking,
try being a Foster Parent!

#2 mugitty

  • Community Member
  • 1,201 posts
  • Real Name:Stuart Owens
  • Location:Great Southeastern Washington Desert, USA

Posted 16 March 2003, 17:25

Well, I managed to get the Admin search in the Categories/Products area so I can search on an item's model # instead of the name. In the query
$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_bimage, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_model, p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and p.products_id = p2c.products_id and pd.products_name like '%" . $HTTP_GET_VARS['search'] . "%' order by p.products_model");
I changed
pd.products_name like '%" . $HTTP_GET_VARS['search'] . "%'
to
p.products_model like '%" . $HTTP_GET_VARS['search'] . "%'
which is great since I usually am going to readily know the products' model number (mine are all unique) if I want to find an item to make an amendment.

What I haven't been able to accomplish is to add this capability as well as keeping the original search on category or product name. I tried just adding a line with an "} else {" statement using the original "pd.products_name", but I get a parse error on the line that contains the additional "} else {"

Anyone have a solution?
:?
... if you want to REALLY see something that doesn't set up right out of the box without some tweaking,
try being a Foster Parent!

#3 clarocque

  • Community Member
  • 559 posts
  • Real Name:Chris
  • Location:VT/USA

Posted 07 March 2004, 07:33

OK I figured out the same as above except I tried to add another }else{ statement and add the original string back in but it wont take it???

Any ideas? Thjis is what I tried
[CODE]
<?php

}



$products_count = 0;

if ($HTTP_GET_VARS['search']) {

$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_bimage, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_model, p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and p.products_id = p2c.products_id and pd.products_model like '%" . $HTTP_GET_VARS['search'] . "%' order by p.products_model");

} else {

$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_bimage, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_model, p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and p.products_id = p2c.products_id and pd.products_name like '%" . $HTTP_GET_VARS['search'] . "%' order by p.products_name");

} else {


$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_bimage, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_model from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = '" . $current_category_id . "' order by p.products_model");

}

But I get

Parse error: parse error in /Library/WebServer/Documents/loaded64/admin/categories.php on line 2225

which is the second else???

Help please.

Edited by clarocque, 07 March 2004, 07:36.

osC Contributions I have published.

Note: Some I only provided minor changes, updates or additions!

#4 bravejoey

  • Community Member
  • 8 posts
  • Real Name:Joey
  • Gender:Male
  • Location:Los Angeles, CA

Posted 07 March 2004, 08:20

Quote

What I haven't been able to accomplish is to add this capability as well as keeping the original search on category or product name. I tried just adding a line with an "} else {" statement using the original "pd.products_name", but I get a parse error on the line that contains the additional "} else {"

Anyone have a solution?

What about something like this? Notice the added ()'s and the OR statement.

$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_bimage, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_model, p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and p.products_id = p2c.products_id and (pd.products_name like '%" . $HTTP_GET_VARS['search'] . "%' or p.products_model like '%" . $HTTP_GET_VARS['search'] . "%') order by p.products_model");

Edited by bravejoey, 07 March 2004, 08:21.


#5 clarocque

  • Community Member
  • 559 posts
  • Real Name:Chris
  • Location:VT/USA

Posted 07 March 2004, 08:32

Ya I just got it to work with " or" I was coming to post it and saw your reply.

Thanks anyway
osC Contributions I have published.

Note: Some I only provided minor changes, updates or additions!