Esempio n. 1
0
 public function viewAction($id = '')
 {
     $item = \Ecommerce\Item::get((int) $id);
     if (!$item) {
         Tools::redirect('/ecommerce/', 'Такой товар не найден');
     }
     $active = $item->category_id;
     $catalog = $item->category;
     $bread = [];
     $bread[] = ['text' => 'Каталог', 'href' => '/ecommerce'];
     $catalogIds = array_values(array_filter(explode('/', $item->tree_path)));
     foreach ($catalogIds as $id) {
         $cat = Ecommerce\Category::get($id);
         if ($cat) {
             $bread[] = ['text' => $cat->name, 'href' => '/ecommerce/itemList/' . $cat->id];
         }
     }
     $bread[] = ['text' => $item->name()];
     $this->view->setTitle($item->name());
     $options = ['data' => compact('item', 'active', 'catalog', 'bread')];
     if (isset($_GET['quickview'])) {
         $options['page'] = 'blank';
     }
     $this->view->addMetaTag(['property' => 'og:title', 'content' => $item->name]);
     $this->view->addMetaTag(['property' => 'og:description', 'content' => $item->description]);
     if ($item->image) {
         $this->view->addMetaTag(['property' => 'og:image', 'content' => 'http://' . INJI_DOMAIN_NAME . $item->image->path]);
     }
     $this->view->addMetaTag(['property' => 'og:url', 'content' => 'http://' . INJI_DOMAIN_NAME . '/view/' . $item->id]);
     $options['content'] = $item->view ? $item->view : 'view';
     $this->view->page($options);
 }