Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Expand fields in Admin search


mugitty

Recommended Posts

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!

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

  • 11 months later...

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

<?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.

osC Contributions I have published.

 

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

Link to comment
Share on other sites

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");

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...