[ Index ]
 

Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/includes/classes/ -> products.php (source)

   1  <?php
   2  /**

   3   * products class

   4   *

   5   * @package classes

   6   * @copyright Copyright 2003-2006 Zen Cart Development Team

   7   * @copyright Portions Copyright 2003 osCommerce

   8   * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0

   9   * @version $Id: products.php 4265 2006-08-25 08:09:36Z drbyte $

  10   */
  11  if (!defined('IS_ADMIN_FLAG')) {
  12    die('Illegal Access');
  13  }
  14  /**

  15   * products class

  16   * Class used for managing various product information

  17   *

  18   * @package classes

  19   */
  20  class products extends base {
  21    var $modules, $selected_module;
  22  
  23    // class constructor

  24    function products($module = '') {
  25    }
  26  
  27    function get_products_in_category($zf_category_id, $zf_recurse=true, $zf_product_ids_only=false) {
  28      global $db;
  29      $za_products_array = array();
  30      // get top level products

  31      $zp_products_query = "select ptc.*, pd.products_name
  32                              from " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc
  33                              left join " . TABLE_PRODUCTS_DESCRIPTION . " pd
  34                              on ptc.products_id = pd.products_id
  35                              and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  36                              where ptc.categories_id='" . (int)$zf_category_id . "'
  37                              order by pd.products_name";
  38  
  39      $zp_products = $db->Execute($zp_products_query);
  40      while (!$zp_products->EOF) {
  41        if ($zf_product_ids_only) {
  42          $za_products_array[] = $zp_products->fields['products_id'];
  43        } else {
  44          $za_products_array[] = array('id' => $zp_products->fields['products_id'],
  45                                       'text' => $zp_products->fields['products_name']);
  46        }
  47        $zp_products->MoveNext();
  48      }
  49      if ($zf_recurse) {
  50        $zp_categories_query = "select categories_id from " . TABLE_CATEGORIES . "
  51                                  where parent_id = '" . (int)$zf_category_id . "'";
  52        $zp_categories = $db->Execute($zp_categories_query);
  53        while (!$zp_categories->EOF) {
  54          $za_sub_products_array = $this->get_products_in_category($zp_categories->fields['categories_id'], true, $zf_product_ids_only);
  55          $za_products_array = array_merge($za_products_array, $za_sub_products_array);
  56          $zp_categories->MoveNext();
  57        }
  58      }
  59      return $za_products_array;
  60    }
  61  
  62    function products_name($zf_product_id) {
  63      global $db;
  64      $zp_product_name_query = "select products_name from " . TABLE_PRODUCTS_DESCRIPTION . "
  65                                  where language_id = '" . $_SESSION['languages_id'] . "'
  66                                  and products_id = '" . (int)$zf_product_id . "'";
  67      $zp_product_name = $db->Execute($zp_product_name_query);
  68      $zp_product_name = $zp_product_name->fields['products_name'];
  69      return $zp_product_name;
  70    }
  71  
  72    function get_admin_handler($type) {
  73      return $this->get_handler($type) . '.php';
  74    }
  75  
  76    function get_handler($type) {
  77      global $db;
  78  
  79      $sql = "select type_handler from " . TABLE_PRODUCT_TYPES . " where type_id = '" . (int)$type . "'";
  80      $handler = $db->Execute($sql);
  81      return $handler->fields['type_handler'];
  82    }
  83  
  84    function get_allow_add_to_cart($zf_product_id) {
  85      global $db;
  86  
  87      $sql = "select products_type from " . TABLE_PRODUCTS . " where products_id='" . (int)$zf_product_id . "'";
  88      $type_lookup = $db->Execute($sql);
  89  
  90      $sql = "select allow_add_to_cart from " . TABLE_PRODUCT_TYPES . " where type_id = '" . (int)$type_lookup->fields['products_type'] . "'";
  91      $allow_add_to_cart = $db->Execute($sql);
  92  
  93      return $allow_add_to_cart->fields['allow_add_to_cart'];
  94    }
  95  
  96  }
  97  ?>


Généré le : Mon Nov 26 16:45:43 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics