Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Direct link to products - no categories


varnco

Recommended Posts

I am going to have a small web site, say only 15 - 20 items.

 

So, I thought of editing the all product listing contribution code so it only lists the product name along with a link directly to the product info page.

 

Procedure would be:

Include allprod.php into a new box in the left column, replacing the categories box in left column. This way, each product shows in the menu, and when clicked, they are taken directly to the product listing.

 

Bonus is that the all products contribution also adds the product name to the URL, so perhaps spiders will pick this up?

 

I am not a php coder... so I'm sure I've missed something/ alot here, or replaced the engine instead of getting an oil change. Maybe there's an easier way?

 

Heres the code

 ?<table border="0" width="190" cellspacing="0" cellpadding="2"> 
? ? ? <tr><td> 
? ? ? ? ? ? <?php ? ?
? ? ? ? ? ? ? ? ? ?
? ? ? ? ?$languages_query = tep_db_query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " order by sort_order"); 
? ? ? ? ?while ($languages = tep_db_fetch_array($languages_query)) { 
? ? ? ? ? ?$languages_array[] = array('id' => $languages['languages_id'], 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'name' => $languages['name'], 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'code' => $languages['code'], 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'image' => $languages['image'], 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'directory' ? => $languages['directory']); 
? ? ? ? ?} 
? ? ? ? ? ? ? ? ? ?for ($i=0; $i<sizeof($languages_array); $i++) 
? ? ? ? ? ? ? ? ? ?{ ? ? ? ? ?
? ? ? ? ? ?$this_language_id = $languages_array[$i]['id']; 
? ? ? ? ? ?$this_language_name = $languages_array[$i]['name']; 
? ? ? ? ? ?$this_language_code = $languages_array[$i]['code']; 
? ? ? ? ? ?$this_language_image = $languages_array[$i]['image']; 
? ? ? ? ? ?$this_language_directory = $languages_array[$i]['directory']; 
? ?echo " <tr>\n";

? ? ? ? ?$products_query = tep_db_query("SELECT s.specials_new_products_price, p.products_id, p.products_model, p.products_price, pd.products_name FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd LEFT JOIN " . TABLE_SPECIALS . " s ON p.products_id=s.products_id WHERE p.products_id = pd.products_id AND p.products_status = 1 AND pd.language_id = $this_language_id ORDER BY pd.products_name");
? ? ? ? ? ? ? ? ? ? ? ? 
? ? ? ? ? ?$products_array = array(); 
? ? ? ? ? ?while($products = tep_db_fetch_array($products_query)) 
? ? ? ? ? ?{ 
? ? ? ? ? ? ? $products_array[] = array('id'=> $products['products_id'], 
? ? ? ? ? ? ? ? ? ? ? ? ? ? 'name' ? ?=> $products['products_name'], 
? ? ? ? ? ? ? ? ? ? ? ? ? ? 'model' ? => $products['products_model'], 
? ? ? ? ? ? ? ? ? ? ? ? ? ? 'price' ? => $products['products_price'], 
? ? ? ? ? ? ? ? ? ? ? ? ? ? 'tax' ? ? => $products['products_tax_class_id'], 
? ? ? ? ? ? ? ? ? ? ? ? ? ? 'special' => $products['specials_new_products_price']); 
? ? ? ? ? ?} 
? ? ? ? ? ? 
? ? ? ? ? ?$num_prods = sizeof($products_array); ?// This optimizes that slow FOR loop... 
? ? ? ? ? ? 
? ? ? ? ? ?for ($i = 0; $i < $num_prods; $i++) ? ?// Traverse Rows 
? ? ? ? ? ?{ 
? ? ?
? ? ? ? ? ? ? $this_id = $products_array[$i]['id']; 
? ? ? ? ? ? ? $this_name = $products_array[$i]['name']; 
? ? ? ? ? ? ? $this_url = tep_href_link(FILENAME_PRODUCT_INFO, ?'name=' . str_replace(" ", "_", $this_name). '&products_id=' . $this_id . (($this_language_code == DEFAULT_LANGUAGE) ? '' : ('&language=' . $this_language_code)), 'NONSSL', false); 

? ? ? ? ? ? ? echo "<tr $row_col>"; 
? ? ? ? ? ? ? echo "<td class='productListing-data' align='left'><a href='$this_url'>$this_name</a></td>"; 
? ? ? ? ? ? ? //echo "<td class='productListing-data' align='center'><a href='$this_url'>$this_model</a></td>"; 
? ? ? ? ? ? ? if (tep_not_null($this_special)) 
? ? ? ? ? ? ? { 
? ? ? ? ? ? ?
? ? ? ? ? ? ? } 
? ? ? ? ? ?
? ? ? ? ? ? ? echo "</tr>\n"; 
? ? ? ? ? ?} 
? ? ? ? } 
? ? ? ? 
? ? ? ? 
? ? ? ? ?
?> 
? ? ? ? ? ?</td> 
? ? ? ? ?</tr> 
? ? ? ?</table>

 

Here's a URL where just the allproducts.php link is, not in a box, so you can see how it links directly to the product info page:

 

http://www.varnco.com/catalog/catalog/allprods.php

 

What's wrong with my solution?

Link to comment
Share on other sites

Here is a much simpler version of the whole infobox. Wondering if we should actually add this as a contribution? Even though it's pretty simple, still... I have not seen any contributions yet for an infobox that gives you just a straight list without cats for sites with not many products.

 

Here it is in action : http://207.44.173.248/roses/index.php

 

And here is the code :

 

<?php
 $info_box_contents = array();
 $info_box_contents[] = array('text' => 'My New Box');

 new infoBoxHeading($info_box_contents, false, false);

 $this_language_id = 1;

 $products_text = "";

 $products_query = tep_db_query("SELECT s.specials_new_products_price, p.products_id, p.products_model, p.products_price, pd.products_name FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd LEFT JOIN " . TABLE_SPECIALS . " s ON p.products_id=s.products_id WHERE p.products_id = pd.products_id AND p.products_status = 1 AND pd.language_id = $this_language_id ORDER BY pd.products_name");

 $products_array = array();
 while($products = tep_db_fetch_array($products_query)) {
   $products_array[] = array('id'=> $products['products_id'],
                             'name'    => $products['products_name'],
                             'model'   => $products['products_model'],
                             'price'   => $products['products_price'],
                             'tax'     => $products['products_tax_class_id'],
                             'special' => $products['specials_new_products_price']);
 }

 $num_prods = sizeof($products_array);  // This optimizes that slow FOR loop...

 for ($i = 0; $i < $num_prods; $i++) {
   $this_id = $products_array[$i]['id'];
   $this_name = $products_array[$i]['name'];
   $this_url = tep_href_link(FILENAME_PRODUCT_INFO,  'products_id=' . $this_id , 'NONSSL', false);

   $products_text .= "<a href='$this_url'>$this_name</a><br>";
 }

 $info_box_contents = array();
 $info_box_contents[] = array('text' => $products_text);

 new infoBox($info_box_contents);
?>

Link to comment
Share on other sites

^ i think that would be cool to have in the contributions. u guys should go ahead.

 

also i'm wondering how to sort by several different categories

like for asian music

 

this would be links on the main page to go to the categories

 

i want for example

 

cd

japanese

chinese

korean

dvd

japanese

chinese

korean

vcd

japanese

chinese

korean

 

but i also want to view all products by

japanese

chinese

korean

 

 

or

 

japanese

cd

dvd

vcd

chinese

cd

dvd

vcd

korean

cd

dvd

vcd

 

also if it's possible to have in every category one product that stands out on the top, with the description right there with it?

Link to comment
Share on other sites

  • 3 weeks later...
Here is a much simpler version of the whole infobox. Wondering if we should actually add this as a contribution? Even though it's pretty simple, still... I have not seen any contributions yet for an infobox that gives you just a straight list without cats for sites with not many products.

 

Here it is in action : http://207.44.173.248/roses/index.php

 

And here is the code :

 

<?php
?$info_box_contents = array();
?$info_box_contents[] = array('text' => 'My New Box');

?new infoBoxHeading($info_box_contents, false, false);

?$this_language_id = 1;

?$products_text = "";

?$products_query = tep_db_query("SELECT s.specials_new_products_price, p.products_id, p.products_model, p.products_price, pd.products_name FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd LEFT JOIN " . TABLE_SPECIALS . " s ON p.products_id=s.products_id WHERE p.products_id = pd.products_id AND p.products_status = 1 AND pd.language_id = $this_language_id ORDER BY pd.products_name");

?$products_array = array();
?while($products = tep_db_fetch_array($products_query)) {
? ?$products_array[] = array('id'=> $products['products_id'],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'name' ? ?=> $products['products_name'],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'model' ? => $products['products_model'],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'price' ? => $products['products_price'],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'tax' ? ? => $products['products_tax_class_id'],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'special' => $products['specials_new_products_price']);
?}

?$num_prods = sizeof($products_array); ?// This optimizes that slow FOR loop...

?for ($i = 0; $i < $num_prods; $i++) {
? ?$this_id = $products_array[$i]['id'];
? ?$this_name = $products_array[$i]['name'];
? ?$this_url = tep_href_link(FILENAME_PRODUCT_INFO, ?'products_id=' . $this_id , 'NONSSL', false);

? ?$products_text .= "<a href='$this_url'>$this_name</a><br>";
?}

?$info_box_contents = array();
?$info_box_contents[] = array('text' => $products_text);

?new infoBox($info_box_contents);
?>

 

Looks pretty good... what I am looking for. I'm guess ing it automatically takes the stuff out of the database?

 

Going to hve to give it a try.

 

You just defined a new infobox, and then called the infobox to appear in your left column, in place of the categories box?

Link to comment
Share on other sites

I am going to have a small web site, say only 15 - 20 items.

 

So, I thought of editing the all product listing contribution code so it only lists the product name along with a link directly to the product info page.

 

Procedure would be:

Include allprod.php into a new box in the left column, replacing the categories box in left column.  This way, each product shows in the menu, and when clicked, they are taken directly to the product listing.

 

Bonus is that the all products contribution also adds the product name to the URL, so perhaps spiders will pick this up?

 

I am not a php coder... so I'm sure I've missed something/ alot here, or replaced the engine instead of getting an oil change. Maybe there's an easier way?

 

Heres the code

 ?<table border="0" width="190" cellspacing="0" cellpadding="2"> 
? ? ? <tr><td> 
? ? ? ? ? ? <?php ? ?
? ? ? ? ? ? ? ? ? ?
? ? ? ? ?$languages_query = tep_db_query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " order by sort_order"); 
? ? ? ? ?while ($languages = tep_db_fetch_array($languages_query)) { 
? ? ? ? ? ?$languages_array[] = array('id' => $languages['languages_id'], 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'name' => $languages['name'], 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'code' => $languages['code'], 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'image' => $languages['image'], 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'directory' ? => $languages['directory']); 
? ? ? ? ?} 
? ? ? ? ? ? ? ? ? ?for ($i=0; $i<sizeof($languages_array); $i++) 
? ? ? ? ? ? ? ? ? ?{ ? ? ? ? ?
? ? ? ? ? ?$this_language_id = $languages_array[$i]['id']; 
? ? ? ? ? ?$this_language_name = $languages_array[$i]['name']; 
? ? ? ? ? ?$this_language_code = $languages_array[$i]['code']; 
? ? ? ? ? ?$this_language_image = $languages_array[$i]['image']; 
? ? ? ? ? ?$this_language_directory = $languages_array[$i]['directory']; 
? ?echo " <tr>\n";

? ? ? ? ?$products_query = tep_db_query("SELECT s.specials_new_products_price, p.products_id, p.products_model, p.products_price, pd.products_name FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd LEFT JOIN " . TABLE_SPECIALS . " s ON p.products_id=s.products_id WHERE p.products_id = pd.products_id AND p.products_status = 1 AND pd.language_id = $this_language_id ORDER BY pd.products_name");
? ? ? ? ? ? ? ? ? ? ? ? 
? ? ? ? ? ?$products_array = array(); 
? ? ? ? ? ?while($products = tep_db_fetch_array($products_query)) 
? ? ? ? ? ?{ 
? ? ? ? ? ? ? $products_array[] = array('id'=> $products['products_id'], 
? ? ? ? ? ? ? ? ? ? ? ? ? ? 'name' ? ?=> $products['products_name'], 
? ? ? ? ? ? ? ? ? ? ? ? ? ? 'model' ? => $products['products_model'], 
? ? ? ? ? ? ? ? ? ? ? ? ? ? 'price' ? => $products['products_price'], 
? ? ? ? ? ? ? ? ? ? ? ? ? ? 'tax' ? ? => $products['products_tax_class_id'], 
? ? ? ? ? ? ? ? ? ? ? ? ? ? 'special' => $products['specials_new_products_price']); 
? ? ? ? ? ?} 
? ? ? ? ? ? 
? ? ? ? ? ?$num_prods = sizeof($products_array); ?// This optimizes that slow FOR loop... 
? ? ? ? ? ? 
? ? ? ? ? ?for ($i = 0; $i < $num_prods; $i++) ? ?// Traverse Rows 
? ? ? ? ? ?{ 
? ? ?
? ? ? ? ? ? ? $this_id = $products_array[$i]['id']; 
? ? ? ? ? ? ? $this_name = $products_array[$i]['name']; 
? ? ? ? ? ? ? $this_url = tep_href_link(FILENAME_PRODUCT_INFO, ?'name=' . str_replace(" ", "_", $this_name). '&products_id=' . $this_id . (($this_language_code == DEFAULT_LANGUAGE) ? '' : ('&language=' . $this_language_code)), 'NONSSL', false); 

? ? ? ? ? ? ? echo "<tr $row_col>"; 
? ? ? ? ? ? ? echo "<td class='productListing-data' align='left'><a href='$this_url'>$this_name</a></td>"; 
? ? ? ? ? ? ? //echo "<td class='productListing-data' align='center'><a href='$this_url'>$this_model</a></td>"; 
? ? ? ? ? ? ? if (tep_not_null($this_special)) 
? ? ? ? ? ? ? { 
? ? ? ? ? ? ?
? ? ? ? ? ? ? } 
? ? ? ? ? ?
? ? ? ? ? ? ? echo "</tr>\n"; 
? ? ? ? ? ?} 
? ? ? ? } 
? ? ? ? 
? ? ? ? 
? ? ? ? ?
?> 
? ? ? ? ? ?</td> 
? ? ? ? ?</tr> 
? ? ? ?</table>

 

Here's a URL where just the allproducts.php link is, not in a box, so you can see how it links directly to the product info page:

 

http://www.varnco.com/catalog/catalog/allprods.php

 

What's wrong with my solution?

Link to comment
Share on other sites

Here is a much simpler version of the whole infobox. Wondering if we should actually add this as a contribution? Even though it's pretty simple, still... I have not seen any contributions yet for an infobox that gives you just a straight list without cats for sites with not many products.

 

Here it is in action : http://207.44.173.248/roses/index.php

 

And here is the code :

 

<?php
?$info_box_contents = array();
?$info_box_contents[] = array('text' => 'My New Box');

?new infoBoxHeading($info_box_contents, false, false);

?$this_language_id = 1;

?$products_text = "";

?$products_query = tep_db_query("SELECT s.specials_new_products_price, p.products_id, p.products_model, p.products_price, pd.products_name FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd LEFT JOIN " . TABLE_SPECIALS . " s ON p.products_id=s.products_id WHERE p.products_id = pd.products_id AND p.products_status = 1 AND pd.language_id = $this_language_id ORDER BY pd.products_name");

?$products_array = array();
?while($products = tep_db_fetch_array($products_query)) {
? ?$products_array[] = array('id'=> $products['products_id'],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'name' ? ?=> $products['products_name'],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'model' ? => $products['products_model'],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'price' ? => $products['products_price'],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'tax' ? ? => $products['products_tax_class_id'],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'special' => $products['specials_new_products_price']);
?}

?$num_prods = sizeof($products_array); ?// This optimizes that slow FOR loop...

?for ($i = 0; $i < $num_prods; $i++) {
? ?$this_id = $products_array[$i]['id'];
? ?$this_name = $products_array[$i]['name'];
? ?$this_url = tep_href_link(FILENAME_PRODUCT_INFO, ?'products_id=' . $this_id , 'NONSSL', false);

? ?$products_text .= "<a href='$this_url'>$this_name</a><br>";
?}

?$info_box_contents = array();
?$info_box_contents[] = array('text' => $products_text);

?new infoBox($info_box_contents);
?>

 

BTW, like you site, with the 3d shadow all the way around... how'd you do that?

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...