productData Class Reference

Traitement sql des cat. More...

Inherits DataStatmentFO, and Interfacedata.

List of all members.

Static Public Member Functions

Static Public Attributes

Static Protected Member Functions

Static Private Member Functions

  • static add_cache ($id)
    Mise en pile de toutes les element des page de cms.
  • static in_cache ()
    Appel et recup des element du cache.
  • static get_products_attribute_stock ($products_id, $attributes=array())
    Calcul des stock avec attribut , pour un jeu d'attribut.

Static Private Attributes


Detailed Description

Traitement sql des cat.

Traitement sql des product.

Definition at line 200 of file driver.product.php.


Member Function Documentation

static productData::add_cache ( id  )  [static, private]

Mise en pile de toutes les element des page de cms.

Definition at line 233 of file driver.product.php.

Referenced by statment_query().

00233                                         {
00234     self::$cache[]=$id;
00235   }

static productData::add_where_query ( add  )  [static, protected]

Ajout constrainte clause where.

Definition at line 292 of file driver.product.php.

Referenced by get_query().

00292 { self::$where_query .=' '.$add; }

static productData::cstr_query ( orderby = '',
limit = '',
option = '' 
) [static, protected]

Requeteur.

Definition at line 303 of file driver.product.php.

Referenced by get_query().

00303                                                                           {
00304 
00305     $query="SELECT distinct p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price,p.track_stock, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id, pd.products_viewed, p2c.categories_id,  p.products_weight, IF(pv.typeID, pv.typeID, 1)  as type
00306           FROM " . TABLE_PRODUCTS . " p left join ".TABLE_PRODUCTS_VIRTUAL." pv on p.products_id = pv.productsID , " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c,  " . TABLE_CATEGORIES . " c
00307           WHERE p.products_status = '1'  and pd.products_id = p.products_id and pd.language_id = '" . self::$lg_id  . "' and p2c.products_id=p.products_id and c.categories_id=p2c.categories_id and c.categories_status='1'  " ;
00308 
00309     $query .=self::$where_query;
00310     $query .=' ORDER BY ' .(!tep_not_null($orderby)? '  p.products_date_added DESC   ' : $orderby) ;
00311     $query .=' LIMIT '.(!tep_not_null($limit)? '1' : $limit) ;
00312 
00313     return $query;
00314   }

static productData::get_attributes_weight ( products_id,
attributes = array() 
) [static]

Calcul du poids.

Definition at line 520 of file driver.product.php.

00520                                                                                   {
00521     $attributes_weight = 0;
00522 
00523     $uprid=tep_get_uprid($products_id, $attributes);
00524     if(isset(self::$array_data[$products_id]->product_attributes_weight) && isset(self::$array_data[$products_id]->product_attributes_weight[$uprid]) ) return self::$array_data[$products_id]->product_attributes_weight[$uprid] ;
00525 
00526     if (is_array($attributes) && count($attributes)>0) {
00527       reset($attributes);
00528       while (list($option, $value) = each($attributes)) {
00529         $attribute_price_query = tep_db_query("select options_values_weight from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
00530         $attribute_price = tep_db_fetch_array($attribute_price_query);
00531         $attributes_weight += $attribute_price['options_values_weight'];
00532       }
00533     }
00534 
00535     return self::$array_data[$products_id]->product_attributes_weight[$uprid] = $attributes_weight;
00536   }

static productData::get_extra_product ( product_id  )  [static]

Champs extra product Recupere la totalite des element supp [extra] => Array ( [MONTANT_PART] => objectInfo Object ( [label] => le montant d'une part [value] => 5 [epf_key] => MONTANT_PART [epf_id] => id epf ) ).

Definition at line 388 of file driver.product.php.

Referenced by statment_query().

00388                                                        {
00389     $array= array();
00390 
00391     if(isset(self::$object_data[(int)$product_id]) && isset(self::$object_data[(int)$product_id]->extra) )$array= self::$object_data[(int)$product_id]->extra;
00392     else {
00393       $DB=Database::getInstance();
00394       $array=array();
00395       $epf_query = $DB->query("SELECT e.epf_id, e.epf_uses_value_list,e.epf_key, epf_show_in_listing, epf_advanced_search, l.epf_active_for_language , l.epf_label, p2epf.products_extra_fields_value as value FROM " . TABLE_PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS . " p2epf , " . TABLE_PRODUCTS_EXTRA_FIELDS . " e JOIN " . TABLE_PRODUCTS_EXTRA_FIELDS_LABELS . " l ON e.epf_id = l.epf_id  WHERE p2epf.products_extra_fields_id=e.epf_id AND products_id = '" . (int)$product_id . "' AND l.languages_id='".self::$lg_id."'  ");
00396 
00397       while( $e = $epf_query->fetchAssoc() ) {
00398         if($e['epf_active_for_language']==1) {
00399           $name_field = "extra_value" . ($e['epf_uses_value_list'] ? '_id' : '') . $e['epf_id'];
00400           $product_query = $DB->query("select " . $name_field . " from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . self::$lg_id . "'");
00401           $field =$product_query->fetchAssoc();
00402 
00403           $name=$field[$name_field];
00404         } else {
00405           $name = $e['value'];
00406         }
00407 
00408         $array[$e['epf_key']]=new objectInfo( array(  'label'=>(string)$e['epf_label'],
00409                                       'value' => $name,
00410                                       'epf_key'=>(string)$e['epf_key'],
00411                                       'epf_id'=>(int)$e['epf_id'],
00412                                       'epf_show_in_listing'=>(int)$e['epf_show_in_listing'],
00413 //                                    'epf_advanced_search'=>(int)$e['epf_advanced_search']
00414                                   ) );
00415       }
00416       if(!isset(self::$object_data[(int)$product_id]))self::$object_data[(int)$product_id]=new objectInfo(array());
00417       self::$object_data[(int)$product_id]->extra = $array;
00418     }
00419 
00420     return $array;
00421   }

static productData::get_has_product_attributes ( products_id  )  [static]

Definition at line 363 of file driver.product.php.

00363                                                                   {
00364     $DB=Database::getInstance();
00365 
00366     $attributes_query = $DB->query("select count(*) as count from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "'");
00367     $attributes = $attributes_query->fetchAssoc();
00368     self::$object_data[(int)$products_id]->has_attributes=($attributes['count'] > 0) ? true : false;
00369     self::$object_data[(int)$products_id]->count_attributes=$attributes['count'];
00370 
00371     return (bool)self::$object_data[(int)$products_id]->has_attributes;
00372   }

static productData::get_item ( id  )  [static]

Alias unique ID.

Definition at line 347 of file driver.product.php.

Referenced by get_products_stock(), and tep_get_products_name().

00347                                       {
00348     $db_list=self::get_query($id);
00349 
00350     if(is_numeric($id) && isset($db_list[(int)$id])){
00351       return $db_list[$id];
00352     }else{
00353       $db_list=self::get_query('',$id);
00354       foreach($db_list as $item)
00355         if((string)$id==(string)$item->name)return $item;
00356     }
00357     return false;
00358   }

productData::get_product_attribut_info ( pID  )  [static]

Retourn tableau asso des element de pId precisé ou false.

Parameters:
$pID int l'id du produits
Returns:
array/false

Definition at line 476 of file driver.product.php.

00476                                                         {
00477     global $page;
00478     if(!isset(self::$array_data[$pID]) || !is_object(self::$array_data[$pID]) ) self::$array_data[$pID]= new objectInfo(array());
00479     if(isset(self::$array_data[$pID]->product_attribut_info)) return self::$array_data[$pID]->product_attribut_info ;
00480 
00481     $language_id=$page->the_var('languages_id');
00482     $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$pID . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int) $language_id. "'");
00483     $products_attributes = tep_db_fetch_array($products_attributes_query);
00484      $products_attributes=  ($products_attributes['total'] > 0)? $products_attributes : array() ;
00485 
00486     return self::$array_data[$pID]->product_attribut_info = $products_attributes;
00487   }

static productData::get_product_attribut_price ( products_id,
attributes = array() 
) [static]

Recuperation price pour attribute.

Definition at line 492 of file driver.product.php.

00492                                                                                       {
00493     $attributes_price = 0;
00494 
00495     $uprid=tep_get_uprid($products_id, $attributes);
00496 
00497     if(!isset(self::$array_data[$products_id]) || !is_object(self::$array_data[$products_id])) self::$array_data[$products_id]=new objectInfo(array());
00498 
00499     if(isset(self::$array_data[$products_id]->product_attribut_price) && isset(self::$array_data[$products_id]->product_attribut_price[$uprid]) ) return self::$array_data[$products_id]->product_attribut_price[$uprid] ;
00500 
00501     if (is_array($attributes) && count($attributes)>0) {
00502       reset($attributes);
00503       while (list($option, $value) = each($attributes)) {
00504         $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
00505         $attribute_price = tep_db_fetch_array($attribute_price_query);
00506         if ($attribute_price['price_prefix'] == '+') {
00507           $attributes_price += $attribute_price['options_values_price'];
00508         } else {
00509           $attributes_price -= $attribute_price['options_values_price'];
00510         }
00511       }
00512     }
00513 
00514     return self::$array_data[$products_id]->product_attribut_price[$uprid] =$attributes_price;
00515   }

static productData::get_product_path ( products_id  )  [static]

Construct a category path to the product TABLES: products_to_categories.

Definition at line 427 of file driver.product.php.

00427                                                          {
00428     $cPath = '';
00429     if((int)$products_id ==0 )return false;
00430     if( ($category=self::get_item($products_id)) == false) return false;
00431     $categories = array();
00432     tep_get_parent_categories($categories, $category->categories_id);
00433     $categories = array_reverse($categories);
00434     $cPath = implode('_', $categories);
00435 
00436     if (tep_not_null($cPath)) $cPath .= '_';
00437     $cPath .= $category->categories_id;
00438 
00439     if(!is_object(self::$object_data[(int)$products_id])) self::$object_data[(int)$products_id]=new objectInfo(array());
00440     self::$object_data[(int)$products_id]->cPath=$cPath;
00441 
00442     return $cPath;
00443   }

static productData::get_products_attribute_stock ( products_id,
attributes = array() 
) [static, private]

Calcul des stock avec attribut , pour un jeu d'attribut.

Parameters:
[in] $products_id int
[in] $attributes tableau attribute id array
Returns:
int quantity

Definition at line 545 of file driver.product.php.

Referenced by get_products_stock().

00545                                                                                          {
00546     global $page;
00547 
00548     self::get_query($products_id);
00549     $uprid=tep_get_uprid($products_id, $attributes);
00550     if(isset(self::$array_data[$products_id]->products_attribute_stock)  && isset(self::$array_data[$products_id]->product_attribut_price[$uprid])  )
00551       return self::$array_data[$products_id]->products_attribute_stock[$uprid] ;
00552     elseif(isset(self::$array_data[$products_id]->products_attribute_stock)  )
00553       self::$array_data[$products_id]->products_attribute_stock=array();
00554 
00555     $languages_id=$page->the_var('languages_id');
00556     $DB=Database::getInstance();
00557     if (is_array($attributes) && count($attributes)>0) {
00558       $attr_list='';
00559       $options_list=implode(",",array_keys($attributes));
00560       $sql="select products_options_id, products_options_track_stock from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id in ($options_list) and language_id= '" . (int)$languages_id . "' order by products_options_id";
00561       $track_stock_query=$DB->query($sql);
00562       while($track_stock_array=$track_stock_query->fetchAssoc())
00563         if ($track_stock_array['products_options_track_stock'])
00564           $attr_list.=$track_stock_array['products_options_id'] . '-' . $attributes[$track_stock_array['products_options_id']] . ',';
00565 
00566       $attr_list=substr($attr_list,0,strlen($attr_list)-1);
00567       unset($track_stock_query);
00568 
00569 
00570       $stock_query=$DB->query($sql="select products_stock_quantity as quantity from " . TABLE_PRODUCTS_STOCK . " where products_id='". (int)$products_id . "' and products_stock_attributes='$attr_list'");
00571       $stock=$stock_query->fetchAssoc();
00572       unset($attr_list);
00573 
00574       @self::$array_data[$products_id]->products_attribute_stock[$uprid] = (int)$stock['quantity'];
00575       return $stock['quantity'];
00576     }
00577     return self::$array_data[$products_id]->products_attribute_stock[$uprid] = 0;
00578   }

static productData::get_products_stock ( products_id,
attributes = array() 
) [static]

Return a product's stock.

Definition at line 449 of file driver.product.php.

00449                                                                                {
00450     $products_id = tep_get_prid($products_id);
00451 
00452     if (sizeof($attributes)>0) {
00453       return (int) self::get_products_attribute_stock($products_id, $attributes);
00454     }
00455     else {
00456       $stock_values=self::get_item($products_id);
00457       return ((!$stock_values)? false : (int)$stock_values->products_quantity );
00458     }
00459   }

static productData::get_query ( id = '',
search = '',
exclude = '',
option = '' 
) [static]

Appel item.

Parameters:
$id 
$search 
$exclude 
$option 

soit id soit sherach name key

Definition at line 324 of file driver.product.php.

Referenced by get_item(), and get_products_attribute_stock().

00324                                                                              {
00325     global $languages_id;
00326 
00327     self::start();
00328     self::reset_query();
00329     $DB=Database::getInstance();
00330     self::$lg_id=(int)$languages_id;
00331     if(empty($option))$option=array();
00332     $search=tep_db_prepare_input($search);
00333 
00334     if (count(self::$cache)>0) self::add_where_query(' AND p.products_id NOT IN ('.self::in_cache().') ');
00336     self::add_where_query((tep_not_null($id) && is_numeric($id) ? " AND p.products_id = '" . (int)$id . "' ": (!empty($search)?" AND pd.products_name LIKE '%" . tep_db_input($search) . "%' ":'') ));
00337     $sql=self::cstr_query((string)@$option['orderby'],(int)@$option['limit'],(array)@$option) ;
00338 
00339     $content_query = $DB->query($sql);
00340 
00341     return self::statment_query($content_query,$exclude,$search);
00342   }

static productData::in_cache (  )  [static, private]

Appel et recup des element du cache.

Definition at line 240 of file driver.product.php.

00240                                     {
00241     return implode("," ,self::$cache);
00242   }

static productData::reset_query (  )  [static, protected]

Definition at line 296 of file driver.product.php.

Referenced by get_query().

00296 { self::$where_query=''; }

static productData::start (  )  [static]

Definition at line 222 of file driver.product.php.

Referenced by product::__construct(), and get_query().

00222                                 {
00223     global $languages_id;
00224     self::$lg_id=(int)$languages_id;
00225     $DB=Database::getInstance();
00226     self::$obj_language = $DB->query("select code from " . TABLE_LANGUAGES . " where languages_id='" .self::$lg_id . "'");
00227   }

static productData::statment_query ( content_query,
exclude = '',
search = '' 
) [static, protected]

Prepa donnée sortie.

module aca

Definition at line 247 of file driver.product.php.

Referenced by get_query().

00247                                                                                  {
00248 
00249     $display_lang=self::$obj_language->fetchAssoc();
00250     if (empty($exclude))$exclude=array();
00251     $tabl=$product=array();
00252     while ($content = $content_query->fetchAssoc()) {
00253       if (!in_array($content['products_name'],$exclude)) {
00254         $product=$content;
00255         $product['href']=tep_href_link(FILENAME_PRODUCT_INFO,'products_id=' . $content['products_id'] . '&language=' . $display_lang['code']);
00256         $product['key']=$content['products_id'];
00257         $product['id']=$content['products_id'];
00258         $product['title']=(tep_not_null($content['products_model'])?$content['products_model']:$content['products_name']);
00259         $product['name']=$content['products_name'];
00260 
00261         $product['extra']=self::get_extra_product($content['products_id']);
00262 
00263         // boolean value If buy possible
00264         if(!_cst_bool('STOCK_ALLOW_CHECKOUT'))
00265           $product['action']['buy']=( ((int)$content['products_quantity']>0 && (int)$content['track_stock']===1) || (int)$content['track_stock']!=1)? true : false;
00266         else
00267           $product['action']['buy']=true;
00268 
00272         $product=product::get_option_data($product);
00273 
00274         self::$object_data[$content['products_id']]=$tabl[$content['products_id']]=new objectInfo($product);
00275         self::$array_data[$content['products_id']]=$product;
00276         self::add_cache($content['products_id']);
00277       }
00278     }
00279 
00280     if((count(self::$object_data)>0))
00281     foreach(self::$object_data as $k=>$content)
00282       if (isset($content->name) && !in_array($content->name,$exclude)) {
00283         if((!empty($search) && strstr($content->name,$search) !=false) || empty($search)) $tabl[$content->id]=$content;
00284       }
00285 
00286     return $tabl;
00287   }

static productData::tep_get_products_name ( product_id,
language = '' 
) [static]

Definition at line 461 of file driver.product.php.

00461                                                                             {
00462     global $languages_id;
00463 
00464     self::$lg_id=(int)(empty($language))? $language : $languages_id;
00465     $products_id = tep_get_prid($products_id);
00466     $stock_values=self::get_item($products_id);
00467     return $stock_values->products_name;
00468   }


Member Data Documentation

productData::$array_data = array() [static]

array cache

Definition at line 214 of file driver.product.php.

Referenced by productModule::load_type_product().

productData::$cache = array() [static]

array

Definition at line 209 of file driver.product.php.

productData::$lg_id [static]

int

Definition at line 205 of file driver.product.php.

productData::$obj_language [static]

obj res db

Definition at line 207 of file driver.product.php.

productData::$object_data [static]

object cache

Definition at line 212 of file driver.product.php.

productData::$where_query = '' [static, private]

string

Definition at line 217 of file driver.product.php.


The documentation for this class was generated from the following file: