Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Is it possible to list all products this way?


Fredrik.r

Recommended Posts

Posted

Hi,

 

I need to list all categories and products nicely in one page, preferably using columns. Please see attached picture. Would this be possible using some contribution? Or could someone quote me doing it tomorrow sunday? ;)

 

allproducts.gif

Posted

There a contribution where you can allow someone to download your catalog online.

 

If that's not what you want, then I think it's better to hand code it yourself...

Posted

Ok, I need to show all categories and products in a page, no download. I don't know exactly how to code this, therefor I asked. Thanks.

Posted

This is a slightly modified version of an existing all products contribution showing the categories/products in blocks.

The layout is controlled by the divs.

Just take a sample page from your site and replace the contents between body_text tags with this code.

 

HTH

Carine

 

 


<!-- body_text //-->
   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
   <td class="breadcrumb" ><?php echo $breadcrumb->trail(' » '); ?>
   </td></tr>
     <tr>
       <td><h2><?php echo HEADING_TITLE; ?></h2></td>
      </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td>
<?php

$language_code = (isset($HTTP_GET_VARS['language']) && tep_not_null($HTTP_GET_VARS['language'])) ? $HTTP_GET_VARS['language'] : DEFAULT_LANGUAGE;

$included_categories_query = tep_db_query("SELECT c.categories_id, c.parent_id, cd.categories_name FROM " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd WHERE c.categories_id = cd.categories_id AND cd.language_id = $languages_id order by categories_name ");

$inc_cat = array();
while ($included_categories = tep_db_fetch_array($included_categories_query)) {
 $inc_cat[] = array (
    'id' => $included_categories['categories_id'],
    'parent' => $included_categories['parent_id'],
    'name' => $included_categories['categories_name']);
 }
$cat_info = array();
for ($i=0; $i<sizeof($inc_cat); $i++)
 $cat_info[$inc_cat[$i]['id']] = array (
   'parent'=> $inc_cat[$i]['parent'],
   'name'  => $inc_cat[$i]['name'],
   'path'  => $inc_cat[$i]['id'],
   'link'  => '' );

for ($i=0; $i<sizeof($inc_cat); $i++) {
 $cat_id = $inc_cat[$i]['id'];
 while ($cat_info[$cat_id]['parent'] != 0){
   $cat_info[$inc_cat[$i]['id']]['path'] = $cat_info[$cat_id]['parent'] . '_' . $cat_info[$inc_cat[$i]['id']]['path'];
   $cat_id = $cat_info[$cat_id]['parent'];
   }
 $link_array = split('_', $cat_info[$inc_cat[$i]['id']] ['path']);
 for ($j=0; $j<sizeof($link_array); $j++) {
   $cat_info[$inc_cat[$i]['id']]['link'] .= '<a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $cat_info[$link_array[$j]]['path']) . '"><nobr>' . $cat_info[$link_array[$j]]['name'] . '</nobr></a> » ';
   }
 }

$products_query = tep_db_query("SELECT p.products_id, pd.products_name, pc.categories_id FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " pc, " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd WHERE c.categories_id = cd.categories_id and cd.language_id = ". $languages_id . " and pc.categories_id = c.categories_id and c.categories_status = '1' and p.products_id = pd.products_id AND p.products_id = pc.products_id AND p.products_status = 1 AND pd.language_id = $languages_id ORDER BY cd.categories_name, pd.products_name");

while($products = tep_db_fetch_array($products_query)) {
 if ($memory == $products['categories_id']) {
  // nothing
 } else {
 	if ($memory) { echo '</div>'; }
   echo '<div width="200" style="float: left;" class="smalltext">';
   echo $cat_info[$products['categories_id']]['link'];
 }
 echo '<br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products['products_id'] . (($language_code == DEFAULT_LANGUAGE) ? '' : ('&language=' . $language_code))) . '">' . $products['products_name'] . '</a>';
 $memory = $products['categories_id'];
}
?>
        </div></td>
     </tr>
     <tr>
       <td align="right" class="main"><br><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL') . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td>
     </tr>
   </table></td>
<!-- body_text_eof //-->

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Archived

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

×
×
  • Create New...