Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace:

Diff

1498
 
1862
 
1862
 
product.php
_> 11 <?php
  22 /*
<> 3 -  $Id: account.php 207 2005-09-26 01:29:31 +0200 (Mo, 26 Sep 2005) hpdl $
   3+  $Id: $
44 
  55   osCommerce, Open Source E-Commerce Solutions
  66   http://www.oscommerce.com
  77 
<> 8 -  Copyright (c) 2006 osCommerce
   8+  Copyright (c) 2007 osCommerce
99 
  1010   This program is free software; you can redistribute it and/or modify
  1111   it under the terms of the GNU General Public License v2 (1991)
     
 !
1515   class osC_Product {
  1616     var $_data = array();
  1717 
<> 18 -    function osC_Product($id) {
   18+    function __construct($id) {
1919       global $osC_Database, $osC_Services, $osC_Language, $osC_Image;
  2020 
<> 21 -      if (!empty($id)) {
  22 -        $Qproduct = $osC_Database->query('select p.products_id as id, p.products_quantity as quantity, p.products_price as price, p.products_tax_class_id as tax_class_id, p.products_date_added as date_added, p.products_date_available as date_available, p.manufacturers_id, pd.products_name as name, pd.products_description as description, pd.products_model as model, pd.products_keyword as keyword, pd.products_tags as tags, pd.products_url as url from :table_products p, :table_products_description pd where');
  23 -        $Qproduct->bindTable(':table_products', TABLE_PRODUCTS);
  24 -        $Qproduct->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
   21+      if ( !empty($id) ) {
   22+        if ( is_numeric($id) ) {
   23+          $Qproduct = $osC_Database->query('select products_id as id, parent_id, products_quantity as quantity, products_price as price, products_model as model, products_tax_class_id as tax_class_id, products_date_added as date_added, manufacturers_id, has_children from :table_products where products_id = :products_id and products_status = :products_status');
   24+          $Qproduct->bindTable(':table_products', TABLE_PRODUCTS);
   25+          $Qproduct->bindInt(':products_id', $id);
   26+          $Qproduct->bindInt(':products_status', 1);
   27+          $Qproduct->execute();
2528 
<> 26 -        if (ereg('^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$', $id)) {
  27 -          $Qproduct->appendQuery('p.products_id = :products_id');
  28 -          $Qproduct->bindInt(':products_id', osc_get_product_id($id));
   29+          if ( $Qproduct->numberOfRows() === 1 ) {
   30+            $this->_data = $Qproduct->toArray();
   31+
   32+            $this->_data['master_id'] = $Qproduct->valueInt('id');
   33+            $this->_data['has_children'] = $Qproduct->valueInt('has_children');
   34+
   35+            if ( $Qproduct->valueInt('parent_id') > 0 ) {
   36+              $Qmaster = $osC_Database->query('select products_id, has_children from :table_products where products_id = :products_id and products_status = :products_status');
   37+              $Qmaster->bindTable(':table_products', TABLE_PRODUCTS);
   38+              $Qmaster->bindInt(':products_id', $Qproduct->valueInt('parent_id'));
   39+              $Qmaster->bindInt(':products_status', 1);
   40+              $Qmaster->execute();
   41+
   42+              if ( $Qmaster->numberOfRows() === 1 ) {
   43+                $this->_data['master_id'] = $Qmaster->valueInt('products_id');
   44+                $this->_data['has_children'] = $Qmaster->valueInt('has_children');
   45+              } else { // master product is disabled so invalidate the product variant
   46+                $this->_data = array();
   47+              }
   48+            }
   49+
   50+            if ( !empty($this->_data) ) {
   51+              $Qdesc = $osC_Database->query('select products_name as name, products_description as description, products_keyword as keyword, products_tags as tags, products_url as url from :table_products_description where products_id = :products_id and language_id = :language_id');
   52+              $Qdesc->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
   53+              $Qdesc->bindInt(':products_id', $this->_data['master_id']);
   54+              $Qdesc->bindInt(':language_id', $osC_Language->getID());
   55+              $Qdesc->execute();
   56+
   57+              $this->_data = array_merge($this->_data, $Qdesc->toArray());
   58+            }
   59+          }
2960         } else {
<> 30 -          $Qproduct->appendQuery('pd.products_keyword = :products_keyword');
   61+          $Qproduct = $osC_Database->query('select p.products_id as id, p.parent_id, p.products_quantity as quantity, p.products_price as price, p.products_model as model, p.products_tax_class_id as tax_class_id, p.products_date_added as date_added, p.manufacturers_id, p.has_children, pd.products_name as name, pd.products_description as description, pd.products_keyword as keyword, pd.products_tags as tags, pd.products_url as url from :table_products p, :table_products_description pd where pd.products_keyword = :products_keyword and pd.language_id = :language_id and pd.products_id = p.products_id and p.products_status = :products_status');
   62+          $Qproduct->bindTable(':table_products', TABLE_PRODUCTS);
   63+          $Qproduct->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
3164           $Qproduct->bindValue(':products_keyword', $id);
<> 32 -        }
   65+          $Qproduct->bindInt(':language_id', $osC_Language->getID());
   66+          $Qproduct->bindInt(':products_status', 1);
   67+          $Qproduct->execute();
3368 
<> 34 -        $Qproduct->appendQuery('and p.products_status = 1 and p.products_id = pd.products_id and pd.language_id = :language_id');
  35 -        $Qproduct->bindInt(':language_id', $osC_Language->getID());
  36 -        $Qproduct->execute();
   69+          if ($Qproduct->numberOfRows() === 1) {
   70+            $this->_data = $Qproduct->toArray();
3771 
<> 38 -        if ($Qproduct->numberOfRows() === 1) {
  39 -          $this->_data = $Qproduct->toArray();
   72+            $this->_data['master_id'] = $Qproduct->valueInt('id');
   73+            $this->_data['has_children'] = $Qproduct->valueInt('has_children');
   74+          }
   75+        }
4076 
<>  77+        if ( !empty($this->_data) ) {
4178           $this->_data['images'] = array();
  4279 
  4380           $Qimages = $osC_Database->query('select id, image, default_flag from :table_products_images where products_id = :products_id order by sort_order');
  4481           $Qimages->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
<> 45 -          $Qimages->bindInt(':products_id', $this->_data['id']);
   82+          $Qimages->bindInt(':products_id', $this->_data['master_id']);
4683           $Qimages->execute();
  4784 
  4885           while ($Qimages->next()) {
     
 !
5188 
  5289           $Qcategory = $osC_Database->query('select categories_id from :table_products_to_categories where products_id = :products_id limit 1');
  5390           $Qcategory->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
<> 54 -          $Qcategory->bindInt(':products_id', $this->_data['id']);
   91+          $Qcategory->bindInt(':products_id', $this->_data['master_id']);
5592           $Qcategory->execute();
  5693 
  5794           $this->_data['category_id'] = $Qcategory->valueInt('categories_id');
  5895 
<> 59 -          $Qcheck = $osC_Database->query('select products_attributes_id from :table_products_attributes patrib where products_id = :products_id limit 1');
  60 -          $Qcheck->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES);
  61 -          $Qcheck->bindInt(':products_id', $this->_data['id']);
  62 -          $Qcheck->execute();
   96+          if ( $this->_data['has_children'] === 1 ) {
   97+            $this->_data['variants'] = array();
6398 
<> 64 -          if ($Qcheck->numberOfRows() === 1) {
  65 -            $this->_data['attributes'] = array();
   99+            $Qsubproducts = $osC_Database->query('select * from :table_products where parent_id = :parent_id and products_status = :products_status');
   100+            $Qsubproducts->bindTable(':table_products', TABLE_PRODUCTS);
   101+            $Qsubproducts->bindInt(':parent_id', $this->_data['master_id']);
   102+            $Qsubproducts->bindInt(':products_status', 1);
   103+            $Qsubproducts->execute();
66104 
<> 67 -            $Qattributes = $osC_Database->query('select pa.*, po.*, pov.* from :table_products_attributes pa, :table_products_options po, :table_products_options_values pov where pa.products_id = :products_id and pa.options_id = po.products_options_id and po.language_id = :language_id and pa.options_values_id = pov.products_options_values_id and pov.language_id = :language_id order by po.products_options_name, pov.products_options_values_name');
  68 -            $Qattributes->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES);
  69 -            $Qattributes->bindTable(':table_products_options', TABLE_PRODUCTS_OPTIONS);
  70 -            $Qattributes->bindTable(':table_products_options_values', TABLE_PRODUCTS_OPTIONS_VALUES);
  71 -            $Qattributes->bindInt(':products_id', $this->_data['id']);
  72 -            $Qattributes->bindInt(':language_id', $osC_Language->getID());
  73 -            $Qattributes->bindInt(':language_id', $osC_Language->getID());
  74 -            $Qattributes->execute();
   105+            while ( $Qsubproducts->next() ) {
   106+              $this->_data['variants'][$Qsubproducts->valueInt('products_id')]['data'] = array('price' => $Qsubproducts->value('products_price'),
   107+                                                                                               'tax_class_id' => $Qsubproducts->valueInt('products_tax_class_id'),
   108+                                                                                               'model' => $Qsubproducts->value('products_model'),
   109+                                                                                               'quantity' => $Qsubproducts->value('products_quantity'),
   110+                                                                                               'weight' => $Qsubproducts->value('products_weight'),
   111+                                                                                               'weight_class_id' => $Qsubproducts->valueInt('products_weight_class'),
   112+                                                                                               'availability_shipping' => 1);
75113 
<> 76 -            while ($Qattributes->next()) {
  77 -              $this->_data['attributes'][] = array('options_id' => $Qattributes->valueInt('options_id'),
  78 -                                                   'options_name' => $Qattributes->value('products_options_name'),
  79 -                                                   'options_values_id' => $Qattributes->valueInt('options_values_id'),
  80 -                                                   'options_values_name' => $Qattributes->value('products_options_values_name'),
  81 -                                                   'options_values_price' => $Qattributes->value('options_values_price'),
  82 -                                                   'price_prefix' => $Qattributes->value('price_prefix'));
   114+              $Qvariants = $osC_Database->query('select pv.default_combo, pvg.id as group_id, pvg.title as group_title, pvg.module, pvv.id as value_id, pvv.title as value_title, pvv.sort_order as value_sort_order from :table_products_variants pv, :table_products_variants_groups pvg, :table_products_variants_values pvv where pv.products_id = :products_id and pv.products_variants_values_id = pvv.id and pvv.languages_id = :languages_id and pvv.products_variants_groups_id = pvg.id and pvg.languages_id = :languages_id order by pvg.sort_order, pvg.title');
   115+              $Qvariants->bindTable(':table_products_variants', TABLE_PRODUCTS_VARIANTS);
   116+              $Qvariants->bindTable(':table_products_variants_groups', TABLE_PRODUCTS_VARIANTS_GROUPS);
   117+              $Qvariants->bindTable(':table_products_variants_values', TABLE_PRODUCTS_VARIANTS_VALUES);
   118+              $Qvariants->bindInt(':products_id', $Qsubproducts->valueInt('products_id'));
   119+              $Qvariants->bindInt(':languages_id', $osC_Language->getID());
   120+              $Qvariants->bindInt(':languages_id', $osC_Language->getID());
   121+              $Qvariants->execute();
   122+
   123+              while ( $Qvariants->next() ) {
   124+                $this->_data['variants'][$Qsubproducts->valueInt('products_id')]['values'][$Qvariants->valueInt('group_id')][$Qvariants->valueInt('value_id')] = array('value_id' => $Qvariants->valueInt('value_id'),
   125+                                                                                                                                                                       'group_title' => $Qvariants->value('group_title'),
   126+                                                                                                                                                                       'value_title' => $Qvariants->value('value_title'),
   127+                                                                                                                                                                       'sort_order' => $Qvariants->value('value_sort_order'),
   128+                                                                                                                                                                       'default' => (bool)$Qvariants->valueInt('default_combo'),
   129+                                                                                                                                                                       'module' => $Qvariants->value('module'));
   130+              }
83131             }
  84132           }
  85133 
<> 86 -          if ($osC_Services->isStarted('reviews')) {
   134+          $this->_data['attributes'] = array();
   135+
   136+          $Qattributes = $osC_Database->query('select tb.code, pa.value from :table_product_attributes pa, :table_templates_boxes tb where pa.products_id = :products_id and pa.languages_id in (0, :languages_id) and pa.id = tb.id');
   137+          $Qattributes->bindTable(':table_product_attributes');
   138+          $Qattributes->bindTable(':table_templates_boxes');
   139+          $Qattributes->bindInt(':products_id', $this->_data['master_id']);
   140+          $Qattributes->bindInt(':languages_id', $osC_Language->getID());
   141+          $Qattributes->execute();
   142+
   143+          while ( $Qattributes->next() ) {
   144+            $this->_data['attributes'][$Qattributes->value('code')] = $Qattributes->value('value');
   145+          }
   146+
   147+          if ( $osC_Services->isStarted('reviews') ) {
87148             $Qavg = $osC_Database->query('select avg(reviews_rating) as rating from :table_reviews where products_id = :products_id and languages_id = :languages_id and reviews_status = 1');
  88149             $Qavg->bindTable(':table_reviews', TABLE_REVIEWS);
<> 89 -            $Qavg->bindInt(':products_id', $this->_data['id']);
   150+            $Qavg->bindInt(':products_id', $this->_data['master_id']);
90151             $Qavg->bindInt(':languages_id', $osC_Language->getID());
  91152             $Qavg->execute();
  92153 
     
 !
97158     }
  98159 
  99160     function isValid() {
<> 100 -      if (empty($this->_data)) {
  101 -        return false;
  102 -      }
  103 -
  104 -      return true;
   161+      return !empty($this->_data);
105162     }
  106163 
<> 107 -    function getData($key) {
  108 -      if (isset($this->_data[$key])) {
   164+    function getData($key = null) {
   165+      if ( isset($this->_data[$key]) ) {
109166         return $this->_data[$key];
  110167       }
  111168 
<> 112 -      return false;
   169+      return $this->_data;
113170     }
  114171 
  115172     function getID() {
  116173       return $this->_data['id'];
  117174     }
  118175 
<>  176+    function getMasterID() {
   177+      return $this->_data['master_id'];
   178+    }
   179+
119180     function getTitle() {
  120181       return $this->_data['name'];
  121182     }
     
 !
157218       if (($with_special === true) && $osC_Services->isStarted('specials') && ($new_price = $osC_Specials->getPrice($this->_data['id']))) {
  158219         $price = '<s>' . $osC_Currencies->displayPrice($this->_data['price'], $this->_data['tax_class_id']) . '</s> <span class="productSpecialPrice">' . $osC_Currencies->displayPrice($new_price, $this->_data['tax_class_id']) . '</span>';
  159220       } else {
<> 160 -        $price = $osC_Currencies->displayPrice($this->_data['price'], $this->_data['tax_class_id']);
   221+        if ( $this->hasVariants() ) {
   222+          $price = 'from&nbsp;' . $osC_Currencies->displayPrice($this->getVariantMinPrice(), $this->_data['tax_class_id']);
   223+        } else {
   224+          $price = $osC_Currencies->displayPrice($this->_data['price'], $this->_data['tax_class_id']);
   225+        }
161226       }
  162227 
  163228       return $price;
  164229     }
  165230 
<>  231+    function getVariantMinPrice() {
   232+      $price = null;
   233+
   234+      foreach ( $this->_data['variants'] as $variant ) {
   235+        if ( ($price === null) || ($variant['data']['price'] < $price) ) {
   236+          $price = $variant['data']['price'];
   237+        }
   238+      }
   239+
   240+      return ( $price !== null ) ? $price : 0;
   241+    }
   242+
   243+    function getVariantMaxPrice() {
   244+      $price = 0;
   245+
   246+      foreach ( $this->_data['variants'] as $variant ) {
   247+        if ( $variant['data']['price'] > $price ) {
   248+          $price = $variant['data']['price'];
   249+        }
   250+      }
   251+
   252+      return $price;
   253+    }
   254+
166255     function getCategoryID() {
  167256       return $this->_data['category_id'];
  168257     }
     
 !
196285     }
  197286 
  198287     function getDateAvailable() {
<> 199 -      return $this->_data['date_available'];
   288+// HPDL
   289+      return false; //$this->_data['date_available'];
200290     }
  201291 
  202292     function getDateAdded() {
  203293       return $this->_data['date_added'];
  204294     }
  205295 
<> 206 -    function hasAttributes() {
  207 -      return (isset($this->_data['attributes']) && !empty($this->_data['attributes']));
   296+    function hasVariants() {
   297+      return (isset($this->_data['variants']) && !empty($this->_data['variants']));
208298     }
  209299 
<> 210 -    function &getAttributes() {
  211 -      global $osC_Currencies;
   300+    function getVariants($filter_duplicates = true) {
   301+      if ( $filter_duplicates === true ) {
   302+        $values_array = array();
212303 
<> 213 -      $array = array();
   304+        foreach ( $this->_data['variants'] as $product_id => $variants ) {
   305+          foreach ( $variants['values'] as $group_id => $values ) {
   306+            foreach ( $values as $value_id => $value ) {
   307+              if ( !isset($values_array[$group_id]) ) {
   308+                $values_array[$group_id]['group_id'] = $group_id;
   309+                $values_array[$group_id]['title'] = $value['group_title'];
   310+                $values_array[$group_id]['module'] = $value['module'];
   311+              }
214312 
<> 215 -      foreach ($this->_data['attributes'] as $attribute) {
  216 -        if (!isset($array[$attribute['options_id']])) {
  217 -          $array[$attribute['options_id']] = array('options_name' => $attribute['options_name'],
  218 -                                                   'values' => array(),
  219 -                                                   'data' => array());
   313+              $value_exists = false;
   314+
   315+              if ( isset($values_array[$group_id]['data']) ) {
   316+                foreach ( $values_array[$group_id]['data'] as $data ) {
   317+                  if ( $data['id'] == $value_id ) {
   318+                    $value_exists = true;
   319+
   320+                    break;
   321+                  }
   322+                }
   323+              }
   324+
   325+              if ( $value_exists === false ) {
   326+                $values_array[$group_id]['data'][] = array('id' => $value_id,
   327+                                                           'text' => $value['value_title'],
   328+                                                           'default' => $value['default'],
   329+                                                           'sort_order' => $value['sort_order']);
   330+              } elseif ( $value['default'] === true ) {
   331+                foreach ( $values_array[$group_id]['data'] as &$existing_data ) {
   332+                  if ( $existing_data['id'] == $value_id ) {
   333+                    $existing_data['default'] = true;
   334+
   335+                    break;
   336+                  }
   337+                }
   338+              }
   339+            }
   340+          }
220341         }
  221342 
<> 222 -        $array[$attribute['options_id']]['values'][] = array('options_values_id' => $attribute['options_values_id'],
  223 -                                                             'options_values_name' => $attribute['options_values_name'],
  224 -                                                             'options_values_price' => $attribute['options_values_price'],
  225 -                                                             'price_prefix' => $attribute['price_prefix']);
   343+        foreach ( $values_array as $group_id => &$value ) {
   344+          usort($value['data'], array('osC_Product', '_usortVariantValues'));
   345+        }
226346 
<> 227 -        $array[$attribute['options_id']]['data'][] = array('id' => $attribute['options_values_id'],
  228 -                                                           'text' => $attribute['options_values_name'] . ($attribute['options_values_price'] != '0' ? ' (' . $attribute['price_prefix'] . $osC_Currencies->displayPrice($attribute['options_values_price'], $this->_data['tax_class_id']) . ')' : ''));
   347+        return $values_array;
229348       }
  230349 
<> 231 -      return $array;
   350+      return $this->_data['variants'];
232351     }
  233352 
<>  353+    function variantExists($variant) {
   354+      return is_numeric($this->getProductVariantID($variant));
   355+    }
   356+
   357+    function getProductVariantID($variant) {
   358+      $_product_id = false;
   359+
   360+      $_size = sizeof($variant);
   361+
   362+      foreach ( $this->_data['variants'] as $product_id => $variants ) {
   363+        if ( sizeof($variants['values']) === $_size ) {
   364+          $_array = array();
   365+
   366+          foreach ( $variants['values'] as $group_id => $value ) {
   367+            $n = sizeof($value);
   368+
   369+            foreach ( $value as $value_id => $value_data ) {
   370+              if ( $n > 1 ) {
   371+                $_array[$group_id][$value_id] = $variant[$group_id][$value_id];
   372+              } else {
   373+                $_array[$group_id] = $value_id;
   374+              }
   375+            }
   376+          }
   377+
   378+          if ( sizeof(array_diff_assoc($_array, $variant)) === 0 ) {
   379+            $_product_id = $product_id;
   380+
   381+            break;
   382+          }
   383+        }
   384+      }
   385+
   386+      return $_product_id;
   387+
   388+/*HPDL; Useful for static version
   389+
   390+        $Qcheck = $osC_Database->query('select products_id from :table_products where parent_id = :parent_id limit 1');
   391+        $Qcheck->bindTable(':table_products', TABLE_PRODUCTS);
   392+        $Qcheck->bindInt(':parent_id', $Qproduct->valueInt('products_id'));
   393+        $Qcheck->execute();
   394+
   395+        if ( $Qcheck->numberOfRows() < 1 ) {
   396+          return true;
   397+        } else {
   398+          $Qvariants = $osC_Database->query('select p.products_id from :table_products p, :table_products_variants pv where p.parent_id = :parent_id and p.products_id = pv.products_id and pv.products_variants_values_id in (":products_variants_values_id") group by pv.products_id');
   399+          $Qvariants->bindTable(':table_products', TABLE_PRODUCTS);
   400+          $Qvariants->bindTable(':table_products_variants', TABLE_PRODUCTS_VARIANTS);
   401+          $Qvariants->bindInt(':parent_id', $Qproduct->valueInt('products_id'));
   402+          $Qvariants->bindRaw(':products_variants_values_id', implode('", "', $variants));
   403+          $Qvariants->execute();
   404+
   405+          while ( $Qvariants->next() ) {
   406+            $Qvcheck = $osC_Database->query('select count(*) as total from :table_products_variants where products_id = :products_id');
   407+            $Qvcheck->bindTable(':table_products_variants', TABLE_PRODUCTS_VARIANTS);
   408+            $Qvcheck->bindInt(':products_id', $Qvariants->valueInt('products_id'));
   409+            $Qvcheck->execute();
   410+
   411+            if ( $Qvcheck->valueInt('total') === sizeof($variants) ) {
   412+              return true;
   413+            }
   414+          }
   415+        }
   416+*/
   417+
   418+    }
   419+
   420+    function hasAttribute($code) {
   421+      return isset($this->_data['attributes'][$code]);
   422+    }
   423+
   424+    function getAttribute($code) {
   425+      if ( !class_exists('osC_ProductAttributes_' . $code) ) {
   426+        if ( file_exists(DIR_FS_CATALOG . 'includes/modules/product_attributes/' . basename($code) . '.php') ) {
   427+          include(DIR_FS_CATALOG . 'includes/modules/product_attributes/' . basename($code) . '.php');
   428+        }
   429+      }
   430+
   431+      if ( class_exists('osC_ProductAttributes_' . $code) ) {
   432+        return call_user_func(array('osC_ProductAttributes_' . $code, 'getValue'), $this->_data['attributes'][$code]);
   433+      }
   434+    }
   435+
234436     function checkEntry($id) {
  235437       global $osC_Database;
  236438 
<> 237 -      $Qcheck = $osC_Database->query('select p.products_id from :table_products p');
  238 -      $Qcheck->bindTable(':table_products', TABLE_PRODUCTS);
   439+      $Qproduct = $osC_Database->query('select p.products_id from :table_products p');
   440+      $Qproduct->bindTable(':table_products', TABLE_PRODUCTS);
239441 
<> 240 -      if (ereg('^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$', $id)) {
  241 -        $Qcheck->appendQuery('where p.products_id = :products_id');
  242 -        $Qcheck->bindInt(':products_id', osc_get_product_id($id));
   442+      if ( is_numeric($id) ) {
   443+        $Qproduct->appendQuery('where p.products_id = :products_id');
   444+        $Qproduct->bindInt(':products_id', $id);
243445       } else {
<> 244 -        $Qcheck->appendQuery(', :table_products_description pd where pd.products_keyword = :products_keyword and pd.products_id = p.products_id');
  245 -        $Qcheck->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
  246 -        $Qcheck->bindValue(':products_keyword', $id);
   446+        $Qproduct->appendQuery(', :table_products_description pd where pd.products_keyword = :products_keyword and pd.products_id = p.products_id');
   447+        $Qproduct->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
   448+        $Qproduct->bindValue(':products_keyword', $id);
247449       }
  248450 
<> 249 -      $Qcheck->appendQuery('and p.products_status = 1 limit 1');
  250 -      $Qcheck->execute();
   451+      $Qproduct->appendQuery('and p.products_status = 1 limit 1');
   452+      $Qproduct->execute();
251453 
<> 252 -      if ($Qcheck->numberOfRows() === 1) {
  253 -        return true;
  254 -      }
  255 -
  256 -      return false;
   454+      return ( $Qproduct->numberOfRows() === 1 );
257455     }
  258456 
  259457     function incrementCounter() {
     
 !
285483 
  286484       return $Qproducts;
  287485     }
<>  486+
   487+    protected static function _usortVariantValues($a, $b) {
   488+      if ( $a['sort_order'] == $b['sort_order'] ) {
   489+        return strnatcasecmp($a['text'], $b['text']);
   490+      }
   491+
   492+      return ( $a['sort_order'] < $b['sort_order'] ) ? -1 : 1;
   493+    }
<_ 288494   }
  289495 ?>