Пример #1
0
 /**
  * This function is used to get the all feartured product page from db.
  *
  * 
  * 
  * @return string
  */
 function getAllFeatured()
 {
     $sql = "SELECT a.*,sum(c.rating)/count(c.user_id) as rating FROM `products_table` a left join product_reviews_table c on a.product_id=c.product_id WHERE category_id IN (SELECT b.category_id AS id FROM category_table a INNER JOIN category_table b ON a.category_id = b.category_parent_id ORDER BY rand()) and is_featured=1 and a.status=1 and a.intro_date <= '" . date('Y-m-d') . "' group by a.product_id limit 0,3";
     $query = new Bin_Query();
     if ($query->executeQuery($sql)) {
         $flag = '0';
         $j = 0;
         $cnt = count($query->records);
         if ($cnt > 0) {
             for ($i = 0; $i < $cnt; $i++) {
                 foreach ($query->records as $row) {
                     $r[$j] = $row;
                     $prid = $row['product_id'];
                     $minval = Core_CWishList::disRates($prid);
                     if ($minval > 0 or $minval != '') {
                         $r[$j]['msrp'] = '$' . number_format($row['msrp'], 2) . ' - $' . number_format($minval, 2);
                     } else {
                         $r[$j]['msrp'] = '$' . number_format($row['msrp'], 2);
                     }
                     $j++;
                 }
             }
             $output = Display_DFeaturedItems::showFeaturedItems($query->records, $flag, $r);
         }
     } else {
         $flag = '1';
         $j = 0;
         $cnt = count($query->records);
         if ($cnt > 0) {
             for ($i = 0; $i < $cnt; $i++) {
                 foreach ($query->records as $row) {
                     $r[$j] = $row;
                     $prid = $row['product_id'];
                     $minval = Core_CWishList::disRates($prid);
                     if ($minval > 0 or $minval != '') {
                         $r[$j]['msrp'] = '$' . number_format($row['msrp'], 2) . ' - $' . number_format($minval, 2);
                     } else {
                         $r[$j]['msrp'] = '$' . number_format($row['msrp'], 2);
                     }
                     $j++;
                 }
             }
             $output = Display_DFeaturedItems::showFeaturedItems($query->records, $flag, $r);
         }
     }
     return $output;
 }
Пример #2
0
 /**
  * This function is used to select the sub category
  * 
  * 
  * @return string
  */
 function selectFeaturedSubCategory()
 {
     //$sql= 'SELECT * FROM `products_table` where category_id in(SELECT category_id FROM category_table WHERE category_id='.(int)$_GET['subcatid'].' and is_featured=1 and category_status=1)';
     $sql = "SELECT * FROM `products_table` where category_id in(SELECT category_id FROM category_table WHERE category_id=" . (int) $_GET['subcatid'] . " and is_featured=1 and intro_date <= '" . date('Y-m-d') . "' and category_status=1)";
     $query = new Bin_Query();
     if ($query->executeQuery($sql)) {
         return Display_DFeaturedItems::showFeaturedItems($query->records);
     } else {
         return "No Products Found";
     }
 }