Example #1
0
 public function check()
 {
     if ($this->Type == self::PRODUCT) {
         $Page = new Content_Page();
         $this->Conflict = $Page->findSize(array('Link = /' . $this->Link)) > 0;
     } else {
         if ($this->Type == self::PAGE) {
             $Product = new Product();
             $this->Conflict = $Product->findSize(array('Slug = ' . ltrim($this->Link, '/'))) > 0;
         }
     }
 }
Example #2
0
 public function category($Category)
 {
     if ($Category instanceof Product_Category && $Category->Id) {
         $Product = new Product();
         $params = array();
         $Layout = $this->getModel();
         $params[] = 'CategoryId = ' . $Category->Id;
         if ($arr = Request::get('b', array())) {
             if (count($arr)) {
                 $params[] = '* BrandId in (' . implode(',', $arr) . ')';
             }
         }
         if ($arr = Request::get('m', array())) {
             if (count($arr)) {
                 $params[] = '* MaterialId in (' . implode(',', $arr) . ')';
             }
         }
         if ($arr = Request::get('t', array())) {
             if (count($arr)) {
                 $params[] = '* TypeId in (' . implode(',', $arr) . ')';
             }
         }
         $Paginator = new Paginator($Product->findSize($params), $this->getLimit(), $this->getPage());
         $Products = $Product->findList($params, 'Position asc', $this->getOffset(), $this->getLimit());
         if (Request::get('ajax')) {
             unset($_GET['ajax']);
             return $this->getView()->htmlItems($Products, $Paginator);
         }
         $custom = array();
         $custom[] = 'CategoryId = ' . $Category->Id;
         $this->getView()->set('Category', $Category);
         $this->getView()->set('Custom', $Product->findList($custom, 'Position asc'));
         $this->getView()->set('Paginator', $Paginator);
         $this->getView()->set('Products', $Products);
         $this->getView()->setMethod('index');
         $this->setContentPage($Category);
         $Page = $this->getContentPage();
         $Page->SeoTitle = $Category->SeoTitle ? $Category->SeoTitle : $Category->Name;
         $Page->SeoDescription = $Category->SeoDescription;
         $Page->SeoKeywords = $Category->SeoKeywords;
         $this->getView()->activeMenu = $Category;
         return $this->getView()->render();
     }
     $this->halt('');
 }