Example #1
0
 protected function boxSearchBlock()
 {
     ClassLoader::import('application.model.category.Category');
     $category = $this->getCategory();
     $search = $this->getCategory()->getPathNodeArray();
     $subCategories = $category->getSubCategoryArray();
     if ($subCategories) {
         if ($category->getID() != Category::ROOT_ID) {
             $search[] = $category->toArray();
         }
         $search = array_merge($search, $subCategories);
     }
     if (!$search) {
         $category = Category::getInstanceById(Category::ROOT_ID, Category::LOAD_DATA);
         $subCategories = $category->getSubCategorySet();
         foreach ($subCategories as $category) {
             $search[] = $category->toArray();
         }
     }
     $options = array(1 => $this->translate('_all_products'));
     foreach ($search as $cat) {
         if ($cat['isEnabled']) {
             $options[$cat['ID']] = $cat['name_lang'];
         }
     }
     $form = new Form($this->getValidator("productSearch", $this->request));
     $form->enableClientSideValidation(false);
     $form->set('id', $this->getCategory()->getID());
     $form->set('q', $this->request->get('q'));
     if ($this->filters && is_array($this->filters)) {
         foreach ($this->filters as $filter) {
             if ($filter instanceof SearchFilter) {
                 $form->set('q', $filter->getKeywords());
             }
         }
     }
     $response = new BlockResponse();
     $response->set('categories', $options);
     $response->set('form', $form);
     return $response;
 }
Example #2
0
 /**
  * @return Form
  */
 private function buildSortForm($order)
 {
     $form = new Form($this->getValidator("productSort", $this->request));
     $form->enableClientSideValidation(false);
     $form->set('sort', $order);
     return $form;
 }