예제 #1
0
 /**
  * @return int
  */
 public function getCategory()
 {
     if (!$this->category instanceof CoreShopCategory) {
         $this->category = CoreShopCategory::getByPath($this->category);
     }
     return $this->category;
 }
 public function listAction()
 {
     $id = $this->getParam("category");
     $page = $this->getParam("page", 0);
     $sort = $this->getParam("sort", "NAMEA");
     $perPage = $this->getParam("perPage", 10);
     $type = $this->getParam("type", "list");
     $category = CoreShopCategory::getById($id);
     if ($category instanceof CoreShopCategory) {
         $this->view->category = $category;
         $this->view->paginator = $category->getProductsPaging($page, $perPage, $this->parseSorting($sort));
         $this->view->page = $page;
         $this->view->sort = $sort;
         $this->view->perPage = $perPage;
         $this->view->type = $type;
         $this->view->seo = array("image" => $category->getImage(), "description" => $category->getMetaDescription() ? $category->getMetaDescription() : $category->getDescription());
         $this->view->headTitle($category->getMetaTitle() ? $category->getMetaTitle() : $category->getName());
     } else {
         throw new CoreShop\Exception(sprintf('Category with id "%s" not found', $id));
     }
 }
예제 #3
0
 /**
  * Check if Product is in Categry
  *
  * @param Object\CoreShopCategory $category
  * @return bool
  */
 public function inCategory(Object\CoreShopCategory $category)
 {
     foreach ($this->getCategories() as $c) {
         if ($c->getId() == $category->getId()) {
             return true;
         }
     }
     return false;
 }