Пример #1
0
 public function actionShow($id)
 {
     $this->good = $this->goods->get($id);
     if (!$this->good) {
         $this->flashMessage('Výrobek se nepodařilo načíst.', 'danger');
         $this->redirect(':Front:Catalog:default');
     }
     $goodsSimilar = array();
     $goodsSameManufacturer = $this->goods->createSelectionInstance()->where("manufacturer_id = ?", $this->good->manufacturer->id)->order('id DESC')->limit(2);
     $goodCG = $this->good->related('category_goods');
     $goodCategoryIds = array();
     foreach ($goodCG as $cg) {
         $goodCategoryIds[] = $cg->category->id;
     }
     $goodsSimilarCG = $this->categoryGoods->createSelectionInstance()->where('category_id IN ?', $goodCategoryIds);
     foreach ($goodsSimilarCG as $cg) {
         if ($cg->good->id == $this->good->id) {
             continue;
         }
         $goodsSimilar[] = $cg->good;
     }
     foreach ($goodsSameManufacturer as $good) {
         if ($good->id == $this->good->id) {
             continue;
         }
         $goodsSimilar[] = $good;
     }
     $this->goodsSimilar = array_unique($goodsSimilar);
 }
Пример #2
0
 /**
  * @param $goodsId
  * @throws Nette\Application\BadRequestException
  * @internal param $id
  */
 public function actionCreate($goodsId)
 {
     $goods = $this->goods->get($goodsId);
     if (!$goods) {
         $this->error('Výrobek, k kterému nahráváte fotografie, nebyl nalezen v databázi.', 404);
     }
     $this->template->goods = $goods;
 }
Пример #3
0
 public function actionToggleRecommended($id)
 {
     $item = $this->item->get($id);
     if (!$item) {
         $this->error('Data pod ID ' . $id . ' nebyla nalezena v databázi.', 404);
     }
     $item->update(array('recommended' => !$item->recommended));
     $this->flashMessage('Doporučení výrobku ' . $item->name . " bylo změněno.", 'success');
     $this->redirect('default');
 }
Пример #4
0
 public function actionCreate($id)
 {
     if ($good = $this->goods->get($id)) {
         $saleId = $this->sale->insert(['goods_id' => $id, 'enable' => 0, 'color' => '#333333', 'bgcolor' => '#FFFFF8', 'border' => '#FFFF33', 'start' => new \DateTime('now')]);
         $this->flashMessage('Akce k výrobku ' . $good->manufacturer->name . ' ' . $good->name . ' byla vytvořena.', 'success');
         $this->redirect('edit', $saleId);
     } else {
         $this->flashMessage('Vytvoření akce selhalo.', 'danger');
         $this->redirect('default');
     }
 }