If this is your first visit, check our documentation. To post, register or login.
Forums / Setting Up Your Zen Cart Products / Setting Up Categories, Products, Attributes / Just need to retrieve all products and their links by category

Just need to retrieve all products and their links by category

Locked

Started by nuwanda on 6 Nov 2009, 7:18 AM · Views: 1,119

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
6 Nov 2009, 7:18 AM
#1
nuwanda avatar

nuwanda

New Zenner

Join Date:
Apr 2008
Posts:
24
Plugin Contributions:
0

Post #1 by nuwanda

V1.3.8

I want to display a very simple category page that shows only the titles of the products in that category. I'll need the associated link to the product as well.

[I know the product display template calls the tabular display template]

Does Zen Cart possess a function that allows me return an array for all products in a category?

7 Nov 2009, 6:06 AM
#2
nuwanda avatar

nuwanda

New Zenner

Join Date:
Apr 2008
Posts:
24
Plugin Contributions:
0

Post #2 by nuwanda

I've got this solved.

18 Nov 2009, 9:02 PM
#3
knu_o2 avatar

knu_o2

New Zenner

Join Date:
Nov 2009
Posts:
4
Plugin Contributions:
0

Post #3 by knu_o2

It would be nice to know how you fixed it :mellow:

18 Nov 2009, 10:56 PM
#4
nuwanda avatar

nuwanda

New Zenner

Join Date:
Apr 2008
Posts:
24
Plugin Contributions:
0

Post #4 by nuwanda

Sure.

here's the code from my common/tpl_modules_product_listing.php

<?php /** * Module Template * * @package templateSystem * @copyright Copyright 2003-2005 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license <http://www.zen-cart.com/license/2_0.txt> GNU Public License V2.0 * @version $Id: tpl_modules_product_listing.php 3241 2006-03-22 04:27:27Z ajeh $ */ include(DIR_WS_MODULES . zen_get_module_directory(FILENAME_PRODUCT_LISTING)); ?> <?php // if ($show_top_submit_button == true or $show_bottom_submit_button == true or (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0 and $show_submit == true and $listing_split->number_of_rows > 0)) { if ($show_top_submit_button == true or $show_bottom_submit_button == true) { ?> </form> <?php }

/*** custom product listing code ***/

if($cPath){

//explodes cPath if in format eg. 6_12 -- also parses single cat numbers eg. 6
$pieces = explode("_", $cPath);
//$product_cat is rightmost cat
$product_cat=$pieces[count($pieces)-1];

$content = '';
$content .= '<div id="categoryProductsList-' . $product_cat . '" class="categoryProductsList">';

$product_query = "
SELECT a.products_id, b.products_id, b.products_name
FROM " . TABLE_PRODUCTS . " a, " . TABLE_PRODUCTS_DESCRIPTION . " b
WHERE a.products_id = b.products_id && a.master_categories_id = $product_cat
ORDER BY b.products_name";

$product_result = $db->Execute($product_query);
?>

<?php $content .= "<ul>"; while (!$product_result->EOF) { $content .= '<li><a href="' . zen_href_link(zen_get_info_page($product_result->fields['products_id']), ($product_cat > 0 ? 'cPath=' . $product_cat . '&' : '') . 'products_id=' . $product_result->fields['products_id']) . '">' . $product_result->fields['products_name'] . '</a></li>'; $product_result->MoveNext(); }; $content .= "</ul>"; ?> <?php $content .= '</div>'; echo $content; }//end if cPath ?>