Get the book

Go Back   Zen Cart Support > Setting Up Your Zen Cart Products > Setting Up Categories and Products

Setting Up Categories and Products Discussion about setting up your products and categorizing them.

Reply
 
Thread Tools Display Modes
Old 6th November 2009, 08:18 AM   #1
Nuwanda
New Zenner
 
Join Date: Apr 2008
Posts: 22
Default Just need to retrieve all products and their links by category

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?
Nuwanda is offline   Reply With Quote
Old 7th November 2009, 07:06 AM   #2
Nuwanda
New Zenner
 
Join Date: Apr 2008
Posts: 22
Default Re: Just need to retrieve all products and their links by category

I've got this solved.
Nuwanda is offline   Reply With Quote
Old 7th November 2009, 09:30 AM   #3
prettywish126
New Zenner
 
prettywish126's Avatar
 
Join Date: Nov 2009
Location: i will tell u later
Posts: 6
Default Re: Just need to retrieve all products and their links by category

congratulations to you
__________________
No pain, No game
prettywish126 is offline   Reply With Quote
Old 18th November 2009, 10:02 PM   #4
knu-o2
New Zenner
 
Join Date: Nov 2009
Posts: 1
Default Re: Just need to retrieve all products and their links by category

It would be nice to know how you fixed it
knu-o2 is offline   Reply With Quote
Old 18th November 2009, 11:56 PM   #5
Nuwanda
New Zenner
 
Join Date: Apr 2008
Posts: 22
Default Re: Just need to retrieve all products and their links by category

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

?>
Nuwanda is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to place the home category links above products? JHouse Page Layout Changes 0 1st July 2009 09:09 AM
Category/Products links on left and top of page ? RandyNiles Page Layout Changes 1 28th February 2009 11:25 PM
Remove Category Links for All Products websightdesign General Questions 2 30th June 2008 01:16 PM
Removing category image links and text links from the HOME page EddieMac Basic Configuration 2 24th April 2008 03:53 PM
How to Add Category Links and remove New Products... BrianL Page Layout Changes 1 11th February 2008 12:05 PM


All times are GMT +1. The time now is 12:00 AM.

Learn tips, tricks & secrets for your Zen Cart™
Sign up for our FREE Newsletter

Powered by vBulletin® Version 3.7.6
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content and Graphics Copyright (c) 2006, 2007, 2008, 2009 Zen Ventures, LLC - all rights reserved
Get Zen Cart E-Commerce Shopping Cart at SourceForge.net. Fast, secure and Free Open Source software downloads