Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Product detail page as the category page


teacup

Recommended Posts

Hello All,

 

I have list of categories and each category contains only one product. When I click on each category, it will show the product with small description and two buttons (Details and Add to Cart) here is the link: http://www.alconoxcanada.ca/index.php?cPath=15

When I click on "Details" button I see the description of the product (http://www.alconoxcanada.ca/product_info.php?products_id=59)

 

Since I have only one product and won't have more, I would like to be able to click on the category menu on the left and get directy to the product detail (http://www.alconoxcanada.ca/product_info.php?products_id=59) and not the small description of the product :http://www.alconoxcanada.ca/index.php?cPath=15 which I currenty have.

 

I suspect I have to look into couple of files such as index.php or product_info.php but I am not sure.

Can you please help newbie? :blink:

 

Thanks a lot,

Link to comment
Share on other sites

The category list on the left is constructed in /catalog/includes/boxes/categories.php

 

I also wanted to do this and the change I made was this:

 

Find, in /catalog/includes/boxes/categories.php:

    

  if ($tree[$counter]['parent'] == 0) {
     $cPath_new = 'cPath=' . $counter;
   } else {
     $cPath_new = 'cPath=' . $tree[$counter]['path'];
   }

   $categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">';

 

Replace this with

 

//mod by RG to jump straight to product if category contains only one product
//if the category has only one product in it, then add a path directly to the product here

   if ($tree[$counter]['parent'] == 0) {
     $cPath_new = 'cPath=' . $counter;
     $cat_id = $counter;
     } else {
     $cPath_new = 'cPath=' . $tree[$counter]['path'];
     $cat_id = $tree[$counter]['path'];
   }

     $products_in_category = tep_count_products_in_category($counter);

     if ($products_in_category == 1) {
  $product_id_query = tep_db_query("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES .  " where categories_id ='". (int)$cat_id ."'");
     $product_id_array = tep_db_fetch_array($product_id_query);
     $product_id=$product_id_array['products_id'];
     if ($product_id<>0) { 
    $product_id_string = "?cpath=".(int)$cat_id."&products_id=" .(int)$product_id;   
     	$categories_string .= tep_href_link(FILENAME_PRODUCT_INFO). $product_id_string . '">';
     } else {   
        $categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">';
     }
     } else {   
        $categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">';
     }
//end of RG mod

 

Works for me anyway.

www.jyoshna.com. Currently using OsC with STS, Super Download Store, Categories Descriptons, Manufacturers Description, Individual Item Status, Infopages unlimited, Product Sort, Osplayer with flashmp3player, Product Tabs 2.1 with WebFx Tabpane and other bits and pieces including some I made myself. Many thanks to all whose contributions I have used!

Link to comment
Share on other sites

  • 2 months later...

it worked like a charm!

 

Thanks A LOT Ben, really appreciate your help!!! :thumbsup:

 

The category list on the left is constructed in /catalog/includes/boxes/categories.php

 

I also wanted to do this and the change I made was this:

 

Find, in /catalog/includes/boxes/categories.php:

    

  if ($tree[$counter]['parent'] == 0) {
     $cPath_new = 'cPath=' . $counter;
   } else {
     $cPath_new = 'cPath=' . $tree[$counter]['path'];
   }

   $categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">';

 

Replace this with

 

//mod by RG to jump straight to product if category contains only one product
//if the category has only one product in it, then add a path directly to the product here

   if ($tree[$counter]['parent'] == 0) {
     $cPath_new = 'cPath=' . $counter;
     $cat_id = $counter;
     } else {
     $cPath_new = 'cPath=' . $tree[$counter]['path'];
     $cat_id = $tree[$counter]['path'];
   }

     $products_in_category = tep_count_products_in_category($counter);

     if ($products_in_category == 1) {
  $product_id_query = tep_db_query("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES .  " where categories_id ='". (int)$cat_id ."'");
     $product_id_array = tep_db_fetch_array($product_id_query);
     $product_id=$product_id_array['products_id'];
     if ($product_id<>0) { 
    $product_id_string = "?cpath=".(int)$cat_id."&products_id=" .(int)$product_id;   
     	$categories_string .= tep_href_link(FILENAME_PRODUCT_INFO). $product_id_string . '">';
     } else {   
        $categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">';
     }
     } else {   
        $categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">';
     }
//end of RG mod

 

Works for me anyway.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...