예제 #1
0
 public function renderDefault()
 {
     //uvod
     $home = dibi::fetch("SELECT * FROM [menu_item] WHERE home = 1 AND lang = %s", $this->lang);
     if (!$home) {
         $home = dibi::fetch("SELECT * FROM [menu_item] WHERE lang = %s", $this->lang, "ORDER BY sequence LIMIT 1");
     }
     $this->template->id_menu_item = $home['id_menu_item'];
     /*
      * META INFO
      */
     $this['header']->addTitle($home['meta_title']);
     $this['header']->setDescription($home['meta_description']);
     $node = $this->getService('Node');
     $query = $node->getAll($this->template->id_menu_item);
     $this->template->node_list = $query->fetchAll();
     //produkty na uvode
     $list = dibi::select('id_product')->from('product')->where('home = 1');
     $count_list = clone $list;
     $count = $count_list->removeClause('select')->select('COUNT(id_product)')->fetchSingle();
     $vp = new VisualPaginator($this, 'paginator');
     $paginator = $vp->getPaginator();
     $paginator->itemsPerPage = 12;
     $paginator->itemCount = (int) $count;
     $this->template->products = $list->limit($paginator->offset . ',' . $paginator->itemsPerPage)->fetchAll();
     $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);
     }
     /* widget */
     $this['productNewsSaleAvaiableTable']->setIdLang($this->id_lang);
     $this['productNewsSaleAvaiableTable']->setUser($this->user);
 }
예제 #2
0
 public function renderDefault($id, $id_category)
 {
     if (!$id) {
         throw new NBadRequestException('Product neexistuje');
     }
     $this->template->id_category = $id_category;
     $this->template->category_parents = CategoryModel::getParents($this->template->id_category, $this->id_lang);
     $this->template->product = ProductModel::getProductWithParams($id, $this->id_lang, $this->user);
     $this['productNewsSaleAvaiableTable']->setIdProduct($id);
     $this['productNewsSaleAvaiableTable']->setIdCategory($id_category);
     $this['productNewsSaleAvaiableTable']->setIdLang($this->id_lang);
     $this['productNewsSaleAvaiableTable']->setUser($this->user);
     /*
      * META INFO
      */
     if ($this->template->product) {
         if ($this->template->product['meta_title'] == '') {
             $this['header']->addTitle($this->template->product['name']);
         } else {
             $this['header']->addTitle($this->template->product['meta_title']);
         }
         if ($this->template->product['meta_description'] == '') {
             $this['header']->setDescription($this->template->product['name']);
         } else {
             $this['header']->setDescription($this->template->product['meta_description']);
         }
         $this['header']->addKeywords($this->template->product['meta_keywords']);
     }
     $this['header']['js']->addFile('jquery/bubblepopup/jquery.bubblepopup.v2.3.1.min.js');
     $this['header']['css']->addFile('../jscripts/jquery/bubblepopup/jquery.bubblepopup.v2.3.1.css');
 }
예제 #3
0
    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);
    }
예제 #4
0
 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;
 }
예제 #5
0
    function actionDefault($q = NULL, $sale = 0, $news = 0, $top = 0)
    {
        $this->q = str_replace('%', '', $q);
        $this->sale = $sale;
        $this->news = $news;
        $this->top = $top;
        $this->template->showForm = true;
        $list = self::getQuery();
        if ($this->sale == 1) {
            $list->where('product.sale = 1');
            $this->template->name = 'Akciový tovar';
            $this->template->showForm = false;
        }
        if ($this->news == 1) {
            $list->where('product.news = 1');
            $this->template->name = 'Novinky';
            $this->template->showForm = false;
        }
        if ($this->top == 1) {
            $list->where('product.our_tip = 1');
            $this->template->name = 'TOP Produkty';
            $this->template->showForm = false;
        }
        if ($this->q != '') {
            $list->where('
					(
					product_lang.name LIKE %s', '%' . $this->q . '%', '
					OR product_lang.description LIKE %s', '%' . $this->q . '%', '
					OR product_param.code LIKE %s', $this->q, '
					)
					');
            $this->template->name = 'Vyhľadávanie slova: ' . $this->q;
        }
        $list->groupBy('id_product');
        /*
         * breadcrumb
         */
        if (!isset($this->template->name)) {
            $this->template->name = 'Vyhľadávanie';
        }
        $this->template->breadcrumb = array();
        $this->template->breadcrumb[] = array('link' => $this->link('this'), 'name' => $this->template->name);
        //		$count_list = clone $list;
        $count = $this->template->count = count($list);
        $vp = new VisualPaginator($this, 'paginator');
        $paginator = $vp->getPaginator();
        $paginator->itemsPerPage = 70;
        $paginator->itemCount = (int) $count;
        $this->template->products = $list->limit($paginator->offset . ',' . $paginator->itemsPerPage)->fetchAll();
        $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);
        }
    }
 function render()
 {
     $this->template->setFile(dirname(__FILE__) . '/default.latte');
     if ($this->id_product) {
         $this->template->product_alternative = ProductModel::getProductAlternativeValues($this->id_product, $this->id_lang, $this->user, 'RAND()', 4);
     }
     $this->template->product_news = ProductModel::getFluent($this->id_lang)->removeClause('select')->select('id_product')->where('%if', $this->id_category, 'id_category = %i', $this->id_category, 'AND %end news = 1')->orderBy('RAND()')->limit('0,6')->fetchAll();
     foreach ($this->template->product_news as $k => $product) {
         $this->template->product_news[$k] = ProductModel::getProductWithParams($product->id_product, $this->id_lang, $this->user);
     }
     $this->template->product_sale = ProductModel::getFluent($this->id_lang)->removeClause('select')->select('id_product')->where('%if', $this->id_category, 'id_category = %i', $this->id_category, 'AND %end sale = 1')->orderBy('RAND()')->limit('0,6')->fetchAll();
     foreach ($this->template->product_sale as $k => $product) {
         $this->template->product_sale[$k] = ProductModel::getProductWithParams($product->id_product, $this->id_lang, $this->user);
     }
     $this->template->product_our_tip = ProductModel::getFluent($this->id_lang)->removeClause('select')->select('id_product')->where('%if', $this->id_category, 'id_category = %i', $this->id_category, 'AND %end our_tip = 1')->orderBy('RAND()')->limit('0,6')->fetchAll();
     foreach ($this->template->product_our_tip as $k => $product) {
         $this->template->product_our_tip[$k] = ProductModel::getProductWithParams($product->id_product, $this->id_lang, $this->user);
     }
     $this->template->render();
 }