Example #1
0
 public function displayMain()
 {
     global $smarty;
     $products = Product::loadData($this->p, $this->n, $this->by, $this->way, array('is_sale' => 1, 'brand.active' => 1, 'active' => 1));
     $this->pagination($products['total']);
     $smarty->assign(array('products' => $products['items']));
     return $smarty->fetch('sale.tpl');
 }
Example #2
0
    public function displayMain()
    {
        global $smarty, $link;
        $products = Product::loadData($this->p, $this->n, $this->by, $this->way, $this->filter);
        $this->pagination($products['total']);
        /** 品牌索引 **/
        $filters = array();
        $filters['brand'] = Db::getInstance()->getAll('SELECT fp.id_filter,b.id_brand,b.name,b.id_image,COUNT(fp.id_filter) AS filter_num FROM tm_filter_product fp
LEFT JOIN tm_product_to_category ptc ON (fp.id_product = ptc.id_product)
LEFT JOIN tm_filter f ON (f.id_filter = fp.id_filter)
LEFT JOIN tm_brand b ON (b.id_brand = f.value)
WHERE ptc.id_category = ' . (int) $this->entity->id . ' AND f.`key` = "id_brand"
GROUP BY fp.id_filter');
        /** 特征索引 **/
        $features_result = Db::getInstance()->query('SELECT fp.id_filter,ft.id_feature,ft.name AS feature,fv.name,COUNT(fp.id_filter) AS filter_num FROM tm_filter_product fp
LEFT JOIN tm_product_to_category ptc ON (fp.id_product = ptc.id_product)
LEFT JOIN tm_filter f ON (f.id_filter = fp.id_filter)
LEFT JOIN tm_feature_value fv ON (fv.id_feature_value = f.value)
LEFT JOIN tm_feature ft ON(fv.id_feature = ft.id_feature)
WHERE ptc.id_category =  ' . (int) $this->entity->id . ' AND f.`key` = "id_feature_value"
GROUP BY fp.id_filter');
        $features = array();
        while ($row = Db::getInstance()->nextRow($features_result)) {
            $features[$row['id_feature']]['name'] = $row['feature'];
            $features[$row['id_feature']]['values'][] = $row;
        }
        $filters['feature'] = $features;
        /** 属性索引 **/
        $attribute_result = Db::getInstance()->query('SELECT fp.id_filter,ag.id_attribute_group,ag.name AS `group`,a.name,COUNT(fp.id_filter) AS filter_num FROM tm_filter_product fp
LEFT JOIN tm_product_to_category ptc ON (fp.id_product = ptc.id_product)
LEFT JOIN tm_filter f ON (f.id_filter = fp.id_filter)
LEFT JOIN tm_attribute a ON (f.value = a.id_attribute)
LEFT JOIN tm_attribute_group ag ON(a.id_attribute_group = ag.id_attribute_group)
WHERE ptc.id_category =  ' . (int) $this->entity->id . ' AND f.`key` = "id_attribute"
GROUP BY fp.id_filter');
        $attribute = array();
        while ($row = Db::getInstance()->nextRow($attribute_result)) {
            $attribute[$row['id_attribute_group']]['name'] = $row['group'];
            $attribute[$row['id_attribute_group']]['values'][] = $row;
        }
        $filters['attribute'] = $attribute;
        /** 分类索引 **/
        $filters['categories'] = Db::getInstance()->getAll('SELECT fp.id_filter,c.name, COUNT(fp.id_filter) AS filter_num  FROM tm_filter_product fp
LEFT JOIN tm_filter f ON (f.id_filter = fp.id_filter)
LEFT JOIN tm_product_to_category ptc ON (fp.id_product = ptc.id_product)
LEFT JOIN tm_category c ON (f.value = c.id_category)
WHERE ptc.id_category =  ' . (int) $this->entity->id . ' AND f.`key` = "id_category" AND c.id_parent =  ' . (int) $this->entity->id . '
GROUP BY fp.id_filter');
        /** 结束索引 **/
        $smarty->assign(array('filters' => $filters, 'this_url' => $link->getPage('CategoryView', $this->entity->id), 'products' => $products['items']));
        return $smarty->fetch('category.tpl');
    }
Example #3
0
            echo '<div class="conf">更新分类状态成功</div>';
        }
    }
}
$table = new UIAdminTable('product', 'Product', 'id_product');
$table->header = array(array('sort' => false, 'isCheckAll' => 'productBox[]'), array('name' => 'id_product', 'title' => 'ID', 'width' => '80px', 'filter' => 'string'), array('sort' => false, 'name' => 'image_small', 'isImage' => true, 'title' => '图片'), array('name' => 'name', 'title' => '名称', 'filter' => 'string'), array('name' => 'quantity', 'title' => '库存'), array('name' => 'price', 'title' => '现价', 'width' => '80px', 'filter' => 'string'), array('name' => 'old_price', 'title' => '原价', 'width' => '80px', 'filter' => 'string'), array('name' => 'active', 'title' => '状态', 'filter' => 'bool'), array('name' => 'in_stock', 'title' => '购买', 'filter' => 'bool'), array('name' => 'is_new', 'title' => '新品', 'filter' => 'bool'), array('name' => 'is_sale', 'title' => '热销', 'filter' => 'bool'), array('name' => 'is_top', 'title' => '推荐', 'filter' => 'bool'), array('sort' => false, 'title' => '操作', 'class' => 'text-right', 'isAction' => array('edit', 'view', 'delete')));
$filter = $table->initFilter();
$filter['id_category'] = isset($_GET['id_category']) ? intval($_GET['id_category']) : 1;
if (isset($_GET['id_brand'])) {
    $filter['id_brand'] = intval($_GET['id_brand']);
}
$orderBy = isset($_GET['orderby']) ? Tools::G('orderby') : 'id_product';
$orderWay = isset($_GET['orderway']) ? Tools::G('orderway') : 'desc';
$limit = $cookie->getPost('pagination') ? $cookie->getPost('pagination') : '50';
$p = Tools::G('p') ? Tools::G('p') == 0 ? 1 : Tools::G('p') : 1;
$result = Product::loadData($p, $limit, $orderBy, $orderWay, $filter);
if (isset($errors)) {
    UIAdminAlerts::MError($errors);
}
//导航
$breadcrumb = new UIAdminBreadcrumb();
$breadcrumb->home();
$breadcrumb->add(array('title' => '商品', 'active' => true));
$bread = $breadcrumb->draw();
$btn_group = array(array('type' => 'a', 'title' => '新产品', 'href' => 'index.php?rule=product_edit', 'class' => 'btn-success', 'icon' => 'plus'));
echo UIViewBlock::area(array('bread' => $bread, 'btn_groups' => $btn_group, 'class' => 'col-md-10 col-md-offset-2'), 'breadcrumb');
?>

<div class="col-md-2 sidebar">
	<div class="panel panel-default">
		<div class="panel-body">