Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

redirecting links in search results


sackling

Recommended Posts

Hello,

 

I'm looking for a way to be able to redirect the links to the products listed on a search results page. The way i have my store set up is that i have a custom page for all my items i.e i did not use the oscommerce catalog. When you click on the links in the search it redirect you to the oscommerce catalog. is there anyway i can change the links? It would be best if i could enter the right links in the oscommerce admin, under Products URL and have the page automatically redirect to the "For more information, please visit this products webpage." page.

 

any ideas on how to do this?

 

thanks,

 

Robert

Link to comment
Share on other sites

Change the catalog\product_info.php Move the query code for the product near the beginning of the file so you should end up with something like this:

	$product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
if( tep_db_num_rows($product_info_query) ) {
$product_info = tep_db_fetch_array($product_info_query);
if(tep_not_null($product_info['products_url')) {
header('Location: ' . $product_info['products_url');
tep_exit();
}
}

 

Once the visitor clicks details for a product he should be redirected to the products url site/page.

Link to comment
Share on other sites

Change the catalog\product_info.php Move the query code for the product near the beginning of the file so you should end up with something like this:

	$product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
if( tep_db_num_rows($product_info_query) ) {
$product_info = tep_db_fetch_array($product_info_query);
if(tep_not_null($product_info['products_url')) {
header('Location: ' . $product_info['products_url');
tep_exit();
}
}

 

Once the visitor clicks details for a product he should be redirected to the products url site/page.

 

hmm Im not sure what you mean by "Move the query code for the product near the beginning of the file" but what i took from it is to edit the file and add in what you did which seems to be just

 

if( tep_db_num_rows($product_info_query) ) {

$product_info = tep_db_fetch_array($product_info_query);

if(tep_not_null($product_info['products_url')) {

header('Location: ' . $product_info['products_url');

tep_exit();

}

}

 

so i added it in there but i got some errors. first it said there was unexpected ( instead of ] so i changed it around products url both times. then i got a differant error stating:

Parse error: parse error, unexpected T_STRING

 

which i dont know what to do with. am i going about this wrong?

Link to comment
Share on other sites

I missed the square brackets from the url field of the array. And I said to move the code at the beginning of the file. That includes the entire block of code and not to modify stuff after the html headers are sent because it's useless.

 

So after these lines

  require('includes/application_top.php');

 

you add

 

   $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
  if( tep_db_num_rows($product_info_query) ) {
 $product_info = tep_db_fetch_array($product_info_query);
 if( tep_not_null($product_info['products_url']) ) {
   header('Location: ' . $product_info['products_url']);
   tep_exit();
 }
  }

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...