本文整理汇总了PHP中CategoryModel::get方法的典型用法代码示例。如果您正苦于以下问题:PHP CategoryModel::get方法的具体用法?PHP CategoryModel::get怎么用?PHP CategoryModel::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CategoryModel
的用法示例。
在下文中一共展示了CategoryModel::get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderXml
function renderXml()
{
//$this->id_lang
$list = dibi::fetchAll('
SELECT
product.id_product
FROM
`product`
JOIN category_product USING (id_product)
JOIN category USING (id_category)
WHERE
product.active = 1 AND
product.added = 1 AND
category.active = 1
GROUP BY (id_product)');
$this->template->baseUri = 'http://' . $_SERVER['HTTP_HOST'];
$this->id_lang = 1;
$this->template->items = array();
foreach ($list as $k => $l) {
$this->template->items[$k] = ProductModel::getProductWithParams($l['id_product'], $this->id_lang, NULL);
$this->template->items[$k]['url'] = $this->link(':Front:Product:default', array('id' => $l['id_product'], 'id_category' => $this->template->items[$k]['main_category']));
//zisti nazvy kategorii
$category = array();
foreach ($this->template->items[$k]['categories'] as $cat) {
$tmp = CategoryModel::get($cat['id_category'], $this->id_lang);
$category[] = $tmp['name'];
}
$this->template->items[$k]['categories_name'] = implode(" | ", $category);
}
// dde($this->template->items);
}
示例2: beforeRender
function beforeRender()
{
parent::beforeRender();
$this->template->id_category = $this->id;
$this->template->category_parents = CategoryModel::getParents($this->template->id_category, $this->id_lang);
//ak je iba jeden parent zobraz kategorie, inak zobraz produkty
if (count($this->template->category_parents) == 1) {
$id_parent = current($this->template->category_parents);
$category_list = CategoryModel::getFluent('id_category')->where('id_parent = %i', $id_parent)->fetchAll();
$this->template->categories = array();
foreach ($category_list as $l) {
$_tmp = CategoryModel::get($l->id_category, $this->id_lang);
$_tmp['product_count'] = dibi::fetchSingle("SELECT COUNT(id_product) FROM [product] JOIN [category_product] USING(id_product) WHERE id_category = %i", $l->id_category);
$this->template->categories[] = $_tmp;
}
$this->template->product_count = dibi::fetchSingle("SELECT COUNT(id_product) FROM [product] JOIN [category_product] USING(id_product) WHERE id_category = %i", $this->id);
} else {
$list = dibi::select('id_product')->from('product')->join('category_product')->using('(id_product)')->join('product_param')->using('(id_product)')->where('id_category = ', $this->id, 'AND product.active = 1');
/*
* Filter
*/
$orderSession = $this['quickFilter']->getSession();
// dde($orderSession['order']);
// $orderSession['order'] = 'price';
if ($orderSession['order']) {
$list->orderBy($orderSession['order']);
} else {
$order_array = $this['quickFilter']->getOrderFilterArray();
$list->orderBy(key($order_array));
}
$list->groupBy('id_product');
// dump($order);
// print_r($list);
$count_list = clone $list;
// $count = $count_list->removeClause('select')->select('COUNT(id_product)')->fetchSingle();
$count = count($count_list);
$vp = new VisualPaginator($this, 'paginator');
$paginator = $vp->getPaginator();
$numOnPageSession = $this['quickFilter']->getSession();
if ($numOnPageSession['num']) {
$paginator->itemsPerPage = $numOnPageSession['num'];
} else {
$num_on_page_array = $this['quickFilter']->getNumOnPageFilterArray();
$paginator->itemsPerPage = key($num_on_page_array);
}
$paginator->itemCount = (int) $count;
$this->template->product_count = $count;
$this->template->products = $list->limit($paginator->offset . ',' . $paginator->itemsPerPage)->fetchAll();
//dump($this->template->products);
$this->template->paginator = $paginator;
foreach ($this->template->products as $k => $p) {
$this->template->products[$k] = ProductModel::getProductWithParams($p['id_product'], $this->id_lang, $this->user);
}
// };
}
// print_r($this->template->products);exit;
}