Zen Cart Logo
Forums / All Other Contributions/Addons / $productsInCategory

$productsInCategory

Views: 903

Results 1 to 3 of 3
6 Mar 2011, 12:18 AM
#1
geeker avatar

geeker

New Zenner

Join Date:
Mar 2011
Posts:
52
Plugin Contributions:
0

$productsInCategory

$productsInCategory Could anyone tell me what this function does? I have done a few searches and come up with nothing.

6 Mar 2011, 1:25 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: $productsInCategory

That gets the products in a category

6 Mar 2011, 1:48 AM
#3
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: $productsInCategory

This is a variable ...

One use of it is obtaining all of the Products in a Category or based on the manufacturers_id such as in the listing:

If you were to add this code to the tpl_main_page.php just below the <body> tag, you can see the results as you navigate the Categories -- OR -- Manufacturers and select a Category from the drop down ...

<?php
//$productsInCategory = zen_get_categories_products_list( (($manufacturers_id > 0 && $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0, $display_limit);
  $productsInCategory = zen_get_categories_products_list( (($manufacturers_id > 0 && $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0);
  if (is_array($productsInCategory) && sizeof($productsInCategory) > 0) {
    // build products-list string to insert into SQL query
    foreach($productsInCategory as $key => $value) {
      $list_of_products .= $key . ', ';
    }
    $list_of_products = substr($list_of_products, 0, -2); // remove trailing comma
  }
echo 'Products In Category: ' . $list_of_products . '<br>';
?>

It will get all of the products_id from that current categories level and all of the subcategories ...