/** * 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; }
/** * This function is used to get the snap shot from home page * * . * * @return string */ function snapshotForHome() { if ($_SESSION['user_id'] != '') { $sqlcnt = "select count(*) as temp from wishlist_table where user_id=" . $_SESSION['user_id']; $sql = "SELECT a.product_id, a.title, a.thumb_image, a.msrp,c.soh FROM products_table a\n\t\t\t\t\tINNER JOIN wishlist_table b ON b.product_id = a.product_id inner join product_inventory_table c on \n\t\t\t\t\tc.product_id=a.product_id where user_id=" . $_SESSION['user_id'] . " ORDER BY \n\t\t\t\t\tdate_added DESC LIMIT 0 , 2"; $obj = new Bin_Query(); $obj->executeQuery($sqlcnt); $totalitem = $obj->records[0]['temp']; if ($obj->executeQuery($sql)) { $cnt = count($obj->records); if ($cnt > 0) { $j = 0; for ($i = 0; $i < $cnt; $i++) { foreach ($obj->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_DWishList::snapshotForHome($obj->records, $totalitem, $r); } } } else { $output = Display_DWishList::snapshotElseForHome(); } } else { $output = Display_DWishList::snapshotElseForHome(); } return $output; }