Example #1
0
 public static function linkOtherProduct($productId)
 {
     $otherProductLink = "";
     $products = Product::query(new Product(_QUERY_ALL));
     $prev = new Product(_NONE);
     //上一个
     $next = new Product(_NONE);
     //下一个
     $found = false;
     if (empty($products)) {
         $otherProductLink = "";
     } else {
         foreach ($products as $product) {
             if ($found) {
                 //已经找到,当前这个即为下一个
                 $next = $product;
                 break;
             }
             if ($product->productId === $productId) {
                 //找到当前这个,则标志已经找到
                 $found = true;
             } else {
                 //未找到,则设置当前这个为上一个
                 $prev = $product;
             }
         }
     }
     $otherProductLink = sprintf("\n\t\t\t<a class='f_left' href='%s' title='%s'>上一个:%s</a>\n\t\t\t<a class='f_right' href='%s' title='%s'>下一个:%s</a><a class='clear'></a>\n\t\t\t", empty($prev->productId) || $prev->productId === 0 ? "#" : "pdetail.php?id=" . $prev->productId, empty($prev->productId) || $prev->productId === 0 ? "没有了" : $prev->productName, empty($prev->productId) || $prev->productId === 0 ? "没有了" : $prev->productName, empty($next->productId) || $next->productId === 0 ? "#" : "pdetail.php?id=" . $next->productId, empty($next->productId) || $next->productId === 0 ? "没有了" : $next->productName, empty($next->productId) || $next->productId === 0 ? "没有了" : $next->productName);
     return $otherProductLink;
 }
 public function index($params)
 {
     $id = $params[0];
     $page = isset($params[1]) ? $params[1] : 1;
     $products = array();
     if ($pros = Product::query()->where([['`active`', '=', 1], ['`id_category`', '=', $id]])->order_by('`order`')->take(12)->skip($page * 12)->get()) {
         while ($row = $pros->fetch_assoc()) {
             $pro = new Product($row);
             if ($imgs = Product_Image::query()->where([['`id_product`', '=', $pro->id]])->take(1)->get()) {
                 $images = array();
                 while ($other_row = $imgs->fetch_assoc()) {
                     $image = new Product_Image($other_row);
                     array_push($images, $image);
                 }
                 $pro->images = $images;
                 $imgs->free();
             }
             array_push($products, $pro);
         }
         $pros->free();
     }
     if ($pros = Product::query()->where([['`active`', '=', 1], ['`id_category`', '=', $id]])->order_by('`view`')->take(1)->get()) {
         $featured = null;
         if ($row = $pros->fetch_assoc()) {
             $featured = new Product($row);
             if ($imgs = Product_Image::query()->where([['`id_product`', '=', $featured->id]])->take(1)->get()) {
                 $images = array();
                 while ($other_row = $imgs->fetch_assoc()) {
                     $image = new Product_Image($other_row);
                     array_push($images, $image);
                 }
                 $featured->images = $images;
                 $imgs->free();
             }
         }
         $pros->free();
     }
     if ($count = Product::query(['count(*) as `count`'])->where([['`active`', '=', 1], ['`id_category`', '=', $id]])->get()) {
         if ($row = $count->fetch_assoc()) {
             $cnt = ceil($row['count'] / 12);
         }
         $count->free();
     }
     $this->render('views/category/index.php', ['products' => $products, 'featured_product' => $featured, 'id_cat' => $id, 'page' => $page, 'total_page' => $cnt]);
 }
 public function featured_products()
 {
     $products = array();
     if ($pros = Product::query()->where([['`active`', '=', 1]])->order_by('`view`')->take(10)->get()) {
         while ($row = $pros->fetch_assoc()) {
             $pro = new Product($row);
             if ($imgs = Data_Provider::execute_query('select * from eli_product_image where `id_product`=' . $pro->id . ' limit 1')) {
                 $images = array();
                 if ($other_row = $imgs->fetch_assoc()) {
                     $image = new Product_Image($other_row);
                     array_push($images, $image);
                 }
                 $pro->images = $images;
                 $imgs->free();
             }
             array_push($products, $pro);
         }
         $pros->free();
     }
     $this->render('views/_shared/_featured_product.php', ['products' => $products]);
 }
Example #4
0
 public function index()
 {
     $query = Product::query();
     if (Input::has('category') && Input::has('attribute')) {
         $iCategory = Input::get('category');
         $category_array = explode(',', $iCategory);
         $categories = array();
         $categories = DB::table('bn_products_to_categories')->whereIn('categories_id', $category_array)->get();
         $product_id_array_cat = array();
         foreach ($categories as $cat) {
             $product_id_array_cat[] = $cat->products_id;
         }
         $iattribute = Input::get('attribute');
         $attribute_array = explode(',', $iattribute);
         $attributes = array();
         $attributes = DB::table('bn_products_attributes')->whereIn('options_values_id', $attribute_array)->get();
         $product_id_array_att = array();
         foreach ($attributes as $attr) {
             $product_id_array_att[] = $attr->products_id;
         }
         $common_product_array = array_intersect($product_id_array_cat, $product_id_array_att);
         if (!empty($common_product_array)) {
             $query->whereIn('products_id', $common_product_array);
         } else {
             return $this->response(array('statusCode' => 400, 'statusDescription' => 'Not Found'));
         }
     } elseif (Input::has('category')) {
         $iCategory = Input::get('category');
         $category_array = explode(',', $iCategory);
         $categories = array();
         $categories = DB::table('bn_products_to_categories')->whereIn('categories_id', $category_array)->get();
         $product_id_array = array();
         foreach ($categories as $cat) {
             $product_id_array[] = $cat->products_id;
         }
         if (!empty($product_id_array)) {
             $query->whereIn('products_id', $product_id_array);
         } else {
             return $this->response(array('statusCode' => 400, 'statusDescription' => 'Not Found'));
         }
     } elseif (Input::has('attribute')) {
         $iattribute = Input::get('attribute');
         $attribute_array = explode(',', $iattribute);
         $attributes = array();
         $attributes = DB::table('bn_products_attributes')->whereIn('options_values_id', $attribute_array)->get();
         $product_id_array = array();
         foreach ($attributes as $attr) {
             $product_id_array[] = $attr->products_id;
         }
         if (!empty($product_id_array)) {
             $query->whereIn('products_id', $product_id_array);
         } else {
             return $this->response(array('statusCode' => 400, 'statusDescription' => 'Not Found'));
         }
     }
     // When we get price
     $iPrice = Input::get('price');
     if ($iPrice) {
         $query->where('products_price', '<=', $iPrice);
     }
     // When we get Condition
     $condition = Input::get('condition');
     if ($condition) {
         $query->where('condition', $condition);
     }
     // When we get brand
     $brand = Input::get('brand');
     if ($brand) {
         $query->where('brand', $brand);
     }
     // When we get gender
     $gender = Input::get('gender');
     if ($gender) {
         $query->where('gender', $gender);
     }
     // When we get Age Range
     $age_range = Input::get('age_range');
     if ($age_range) {
         $query->where('age_range', $age_range);
     }
     // When we get Freshly saved
     $freshly_faved = Input::get('freshly_faved');
     if ($freshly_faved) {
         $query->where('freshly_faved', $freshly_faved);
     }
     // When we get order by
     $order_by = Input::get('order');
     if ($order_by) {
         $query->orderBy('created_at', $order_by);
     }
     //  else {	$query->orderBy('created_at', 'desc'); }
     $price_sort = Input::get('price_sort');
     if ($price_sort) {
         $query->orderBy('products_price', $price_sort);
     }
     $products = $query->where('products_status', '1')->paginate(30);
     //->get();
     if ($products) {
         $products = $this->product_add_detail($products);
         return $this->response(array('statusCode' => 100, 'statusDescription' => 'Success', 'products' => json_decode($products->toJson(), true)));
     } else {
         return $this->response(array('statusCode' => 400, 'statusDescription' => 'Not Found'));
     }
 }
Example #5
0
        $newsList = "<b>暂无新闻</b>";
    } else {
        foreach ($contents as $content) {
            $newsList .= sprintf("\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href='ndetail.php?id=%u' title='%s' target='_blank'>%s</a>\n\t\t\t\t\t</li>", $content->contentId, $content->subject, $content->subject);
        }
    }
}
?>

<?php 
//推荐产品
$recommendHtml = "";
if ($sections["recommend"] === 1) {
    $query = new Product(8);
    $query->isRecommend = 1;
    $products = Product::query($query);
    if (empty($products)) {
        $recommendHtml = "<b>暂无产品</b>";
    } else {
        foreach ($products as $product) {
            $recommendHtml .= sprintf("\n\t\t\t\t\t<dl class='l_m_prod'>\n\t\t\t\t\t\t<dd class='f_left'>\n\t\t\t\t\t\t\t<a href='pdetail.php?id=%u' title='%s'>\n\t\t\t\t\t\t\t\t<img src='%s' width='42' height='42' alt='%s' title='%s' class='mm' />\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t</dd>\n\t\t\t\t\t\t<dt class='f_left' style='width:160px;'>\n\t\t\t\t\t\t\t<div class='nowrap'><a href='pdetail.php?id=%u' title='%s'>%s</a></div>\t\t\n\t\t\t\t\t\t\t<div><a href='%s' target='_blank'><img src='images/buy_s.png' width='70px' height='20px' alt='%s' /></a></div>\t\t\n\t\t\t\t\t\t</dt>\n\t\t\t\t\t</dl>", $product->productId, $product->productName, str_replace("../", "", $product->mImage), $product->productName, $product->productName, $product->productId, $product->productName, $product->productName, $product->aliUrl, $product->productName);
        }
    }
}
?>

<?php 
//产品类型
if ($sections["sort"] === 1) {
    $query = new Sort(25);
    $sorts = Sort::query($query);
Example #6
0
require_once $realLibPath . "model/orderDetail.model.php";
require_once $realLibPath . "model/order.model.php";
require_once $realLibPath . "model/product.model.php";
$orderid = $_GET['orderID'];
$order = new Order();
$orderdata = current($order->query(array('status' => '0', 'ID' => $orderid), array()));
//var_dump($orderdata);
$orderDetail = new OrderDetail();
$productArray = $orderDetail->query(array('status' => '0', 'order_id' => $orderid), array('ID', 'pro_ID', 'number'));
//var_dump($productArray);
//获取所有商品信息
//$productArray = array();
if (count($productArray)) {
    foreach ($productArray as $pitem) {
        $product = new Product();
        $productDetail = current($product->query(array('status' => 'Y', 'ID' => $pitem['pro_ID']), array("ID", 'name', 'price', 'realPrice')));
        ?>
		<tr class='product'>
		<td><input type="checkbox"/></td>
		<input type="hidden" value="<?php 
        echo $pitem['ID'];
        ?>
" />
  		<td><?php 
        echo $pitem['pro_ID'];
        ?>
</td>
		<td><?php 
        echo $productDetail['name'];
        ?>
</td>
Example #7
0
<?php 
require_once "../web.config.php";
require_once $realLibPath . "model/product.model.php";
require_once $realLibPath . "model/categoryPro.model.php";
$catPro = new CategoryPro();
$id = $_POST['id'];
$product = new Product();
$array = array("ID" => $id);
$array2 = array();
$result = current($product->query($array, $array2));
$parchildArray = $catPro->getParChildArray();
@($currentPage = $_POST['currentPage']);
require_once $realLibPath . "model/images.model.php";
$img = new Images();
$imgArray = $img->query(array('status' => 'Y'), array('ID', 'href', 'alt'));
/*@$fid=$_POST['fid'];
echo "fid:".$fid;
$childPro=array();
if($fid){
	if($fid!="全部"){
		$childPro=$catPro->getChildrenCat($fid);
	}else{
		$childPro=$catPro->getAllChildrenCat();	
	}
	var_dump($childPro);	
}*/
//var_dump($result);
?>
<!--具体某个商品的详细信息,接收参数id-->
<style>
    .am-form-group {
Example #8
0
?>
		<!--搜索栏和按钮-->
		<input id="search_input" type="text" value="输入您想找的宝贝吧"/>
		<input id="search_button" type="button"/>
		<input id="car_button" type="button" value="购物车共<?php 
echo count($car->query(array('status' => 'Y', 'userID' => $userID), array()));
?>
个商品信息!" />
        <?php 
require_once $realLibPath . "model/product.model.php";
require_once $realLibPath . "model/images.model.php";
/*require_once($realLibPath."model/categoryPro.model.php");
		$cpo = new CategoryPro();*/
$id = $_GET['id'];
$pro = new Product();
$prodata = current($pro->query(array("ID" => $id, "status" => "Y"), array()));
//$cpo->query(array("status"=>"Y","ID"=>$prodata['category']),array());
$relatePro = $pro->query(array("status" => "Y", "category" => $prodata['category']), array());
$relatePro = array_slice($relatePro, 0, 3);
//var_dump($relatePro);
?>
		<!--相关产品-->
		<div class="related_product">
			<!--推荐产品-->
			
			<div class="hot_product">
			<ul class="relateList">        
			</ul>
			<!--页码 数字跟着页码改变-->
			<div class="hp_page"><a href="javascript:void(0)" id='rlfirstPage'>首页</a><a href="javascript:void(0)" id="rlprePage">上一页</a><select id='rlpageNumber'></select>		
			<a href="javascript:void(0)" id='rlnextPage'>下一页</a><a href="javascript:void(0)" id='rllastPage'>尾页</a></div>
Example #9
0
//读取产品数据
if ($module == "product") {
    if ($dataType == "list" || $dataType == "count") {
        $query = new Product($querySize);
        $query->isRecommend = isset($_REQUEST["isRecommend"]) ? intval($_REQUEST["isRecommend"]) : _NONE;
        $query->isShowHome = isset($_REQUEST["isShowHome"]) ? intval($_REQUEST["isShowHome"]) : _NONE;
        $query->productName = strtolower(isset($_REQUEST["keyword"]) ? $_REQUEST["keyword"] : "");
        $query->productType = isset($_REQUEST["productType"]) ? $_REQUEST["productType"] : _NONE;
        $query->isPaging = $isPaging;
        $query->querySize = $querySize;
        $query->curPage = $curPage;
        try {
            $data = null;
            $listJson = "";
            if ($dataType == "list") {
                $data = Product::query($query);
                if (!empty($data)) {
                    $listJson = json_encode($data, JSON_UNESCAPED_UNICODE);
                } else {
                    $listJson = "[]";
                }
                Tool::logger(__METHOD__, __LINE__, sprintf("查询产品Json: %s", $listJson), _LOG_ERROR);
            } else {
                if ($dataType == "count") {
                    $listJson = Product::rcount($query);
                    Tool::logger(__METHOD__, __LINE__, sprintf("查询产品总数: %s", $listJson), _LOG_ERROR);
                }
            }
            echo "{\"status\":\"true\", \"data\": " . $listJson . "}";
        } catch (Exception $e) {
            echo "{\"status\":\"false\", \"data\": \"" . $e->getMessage() . "\"}";