function onAction()
 {
     $request = new Request();
     $category_id = $request->getValueByKey('category_id');
     /*
      *       :
      *                                                     ,                     .
      *                                                         default
      *               AZ (                                 AZ).
      *
      *        :
      *                   Catalog::getProductListByGlobalFilter       ,
      *                                                                                      .
      *                                 default                     .
      */
     //              default
     loadClass('CProductListFilter');
     $f = new CProductListFilter();
     $params = $f->getProductListParamsObject();
     $params->category_id = $category_id;
     $params->select_mode_recursiveness = IN_CATEGORY_ONLY;
     //
     $products_array = modApiFunc('Catalog', 'getProductListByFilter', $params, RETURN_AS_ID_LIST);
     $products = array();
     if (!empty($products_array)) {
         foreach ($products_array as $pinfo) {
             $obj = new CProductInfo($pinfo['product_id']);
             $products[] = array('id' => $pinfo['product_id'], 'name' => $obj->getProductTagValue('Name'));
         }
     }
     global $_RESULT;
     $_RESULT['products'] = $products;
 }
 function CProductSetTagSettings()
 {
     global $application;
     $this->template = array('Directory' => 'catalog/product-set/default/', 'Container' => 'product-set-container.tpl.html', 'ContainerEmpty' => 'product-set-container-empty.tpl.html', 'Item' => 'product-set-item.tpl.html', 'ItemOutOfStock' => 'product-set-item-out-of-stock.tpl.html');
     //                c default
     loadClass('CProductListFilter');
     $f = new CProductListFilter();
     $this->filter = $f->getProductListParamsObject();
     $this->filter->use_paginator = true;
 }
 /**
  * Executes SQL query, which returns the product number in the current
  * category.
  *
  * The product number, which will be returned, depends on the current zone.
  * If the current zone is Customer Zone, then it will be calculated only the
  * products, which:
  * - attribute Available is installed in Yes,
  * - attribute Available is installed in the empty string, (                ,
  *                        ,                       ,     Yes)
  * - attribute Available can't be seen in the product type.
  *
  * If the current zone is Admin Zone, then all products will be calculated.
  *
  * @see CCategoryInfo::_loadProductsNumberInCategory()
  * @param int $calc_mode The constant IN_CATEGORY_ONLY, IN_CATEGORY_RECURSIVELY
  *        or IN_CATEGORY_RECURSIVELY_WITHOUT_CURRENT
  * @return int the number of the products in the current category
  */
 function _loadProductsNumberInCategory($select_mode_recursiveness, $select_mode_uniqueness)
 {
     //           default
     //
     loadClass('CProductListFilter');
     $f = new CProductListFilter();
     $params = $f->getProductListParamsObject();
     //                 default            "      "
     $params->category_id = $this->_fCategoryID;
     $params->select_mode_recursiveness = $select_mode_recursiveness;
     $params->select_mode_uniqueness = $select_mode_uniqueness;
     return execQueryCount('SELECT_PRODUCT_LIST', $params->getParams());
 }
 function getCommonSearchFilter($filter, $field, $wordlist, $pattern_type, $ignore_list)
 {
     $CFilter = new CProductListFilter();
     // setting category
     if (isset($filter['category']) && $filter['category'] != 'all') {
         $CFilter->changeCurrentCategoryId($filter['category']);
     } else {
         $CFilter->product_list_params_obj->category_id = null;
     }
     // setting if category should be searched recursively
     if (isset($filter['recursive'])) {
         $CFilter->product_list_params_obj->select_mode_recursiveness = IN_CATEGORY_RECURSIVELY;
     } else {
         $CFilter->product_list_params_obj->select_mode_recursiveness = IN_CATEGORY_ONLY;
     }
     // setting manufacturer
     if (isset($filter['manufacturer']) && $filter['manufacturer'] != 'all') {
         $CFilter->product_list_params_obj->filter_manufacturer_id_list = array($filter['manufacturer']);
     } else {
         $CFilter->resetManufacturerId();
     }
     // setting min price
     if (is_numeric(@$filter['price_min'])) {
         $CFilter->changeCurrentMinSalePrice($filter['price_min']);
     }
     if (is_numeric(@$filter['price_max'])) {
         $CFilter->changeCurrentMaxSalePrice($filter['price_max']);
     }
     // setting the word criteria for provided fields
     if (isset($filter['in_name']) && $field == 'in_name') {
         $CFilter->product_list_params_obj->filter_product_name_like_values = $wordlist;
         $CFilter->product_list_params_obj->filter_product_name_search_condition = $pattern_type;
     } else {
         $CFilter->product_list_params_obj->filter_product_name_like_values = null;
     }
     if (isset($filter['in_sku']) && $field == 'in_sku') {
         $CFilter->product_list_params_obj->filter_sku_like_values = $wordlist;
         $CFilter->product_list_params_obj->filter_sku_search_condition = $pattern_type;
     } else {
         $CFilter->product_list_params_obj->filter_sku_like_values = null;
     }
     if (isset($filter['in_descr']) && $field == 'in_descr') {
         $CFilter->product_list_params_obj->filter_short_description_like_values = $wordlist;
         $CFilter->product_list_params_obj->filter_short_description_search_condition = $pattern_type;
     } else {
         $CFilter->product_list_params_obj->filter_short_description_like_values = null;
     }
     if (isset($filter['in_det_descr']) && $field == 'in_det_descr') {
         $CFilter->product_list_params_obj->filter_detailed_description_like_values = $wordlist;
         $CFilter->product_list_params_obj->filter_detailed_description_search_condition = $pattern_type;
     } else {
         $CFilter->product_list_params_obj->filter_detailed_description_like_values = null;
     }
     if (isset($filter['in_title']) && $field == 'in_title') {
         $CFilter->product_list_params_obj->filter_page_title_like_values = $wordlist;
         $CFilter->product_list_params_obj->filter_page_title_search_condition = $pattern_type;
     } else {
         $CFilter->product_list_params_obj->filter_page_title_like_values = null;
     }
     if (isset($filter['in_keywords']) && $field == 'in_keywords') {
         $CFilter->product_list_params_obj->filter_meta_keywords_like_values = $wordlist;
         $CFilter->product_list_params_obj->filter_meta_keywords_search_condition = $pattern_type;
     } else {
         $CFilter->product_list_params_obj->filter_meta_keywords_like_values = null;
     }
     if (isset($filter['in_meta_descr']) && $field == 'in_meta_descr') {
         $CFilter->product_list_params_obj->filter_meta_description_like_values = $wordlist;
         $CFilter->product_list_params_obj->filter_meta_description_search_condition = $pattern_type;
     } else {
         $CFilter->product_list_params_obj->filter_meta_description_like_values = null;
     }
     $params = $CFilter->getProductListParamsObject();
     // search by product id (commented out)
     if ($field == 'in_id') {
         // force the list to be non-empty
         $id_list = array(0);
         if (is_array($wordlist)) {
             foreach ($wordlist as $w) {
                 if (is_numeric($w)) {
                     $id_list[] = intval($w);
                 }
             }
         }
         $params->product_id_list_to_select = $id_list;
     }
     // setting list to ignore
     $params->product_id_list_to_ignore = $ignore_list;
     // hide products which have the attributes hidden or undefined
     $params->params['filter']['meta_description']['select_undefined'] = false;
     $params->params['filter']['meta_description']['select_invisible'] = false;
     $params->params['filter']['meta_keywords']['select_undefined'] = false;
     $params->params['filter']['meta_keywords']['select_invisible'] = false;
     $params->params['filter']['page_title']['select_undefined'] = false;
     $params->params['filter']['page_title']['select_invisible'] = false;
     $params->params['filter']['detailed_description']['select_undefined'] = false;
     $params->params['filter']['detailed_description']['select_invisible'] = false;
     $params->params['filter']['short_description']['select_undefined'] = false;
     $params->params['filter']['short_description']['select_invisible'] = false;
     $params->params['filter']['sku']['select_undefined'] = false;
     $params->params['filter']['sku']['select_invisible'] = false;
     // force to limit the result
     $params->setSelectLimits(0, PSF_PRODUCT_SEARCH_RESULT_LIMIT);
     return $params;
 }
 function getCommonSearchFilter()
 {
     //         default        c default
     loadClass('CProductListFilter');
     $f = new CProductListFilter();
     $params = $f->getProductListParamsObject();
     //
     $params->category_id = 1;
     $params->select_mode_recursiveness = IN_CATEGORY_RECURSIVELY;
     $params->select_mode_uniqueness = UNIQUE_PRODUCTS;
     //                                                                      ,
     //
     $params->params['filter']['meta_description']['select_undefined'] = false;
     $params->params['filter']['meta_description']['select_invisible'] = false;
     $params->params['filter']['meta_keywords']['select_undefined'] = false;
     $params->params['filter']['meta_keywords']['select_invisible'] = false;
     $params->params['filter']['page_title']['select_undefined'] = false;
     $params->params['filter']['page_title']['select_invisible'] = false;
     $params->params['filter']['detailed_description']['select_undefined'] = false;
     $params->params['filter']['detailed_description']['select_invisible'] = false;
     $params->params['filter']['short_description']['select_undefined'] = false;
     $params->params['filter']['short_description']['select_invisible'] = false;
     $params->params['filter']['sku']['select_undefined'] = false;
     $params->params['filter']['sku']['select_invisible'] = false;
     //
     $params->setSelectLimits(0, PRODUCT_SEARCH_RESULT_LIMIT);
     return $params;
 }
 /**
  *                                             id                                   .
  *
  *               storefront.         ,             id
  *           id,                                  ,        : offline, out of stock    . .
  *
  *       ,                                         id-         $id_list,
  *                  .
  *
  */
 function filterProductIdListByGlobalFilter($id_list)
 {
     // default
     loadClass('CProductListFilter');
     $f = new CProductListFilter();
     $params_obj = $f->getProductListParamsObject();
     //                       :
     $params_obj->product_id_list_to_select = $id_list;
     //
     $params_obj->category_id = 1;
     $params_obj->select_mode_recursiveness = IN_CATEGORY_RECURSIVELY;
     $params_obj->select_mode_uniqueness = UNIQUE_PRODUCTS;
     $result = execQuery('SELECT_PRODUCT_LIST', $params_obj->getParams());
     $plain_res = array();
     foreach ($result as $item) {
         $plain_res[] = $item['product_id'];
     }
     return array_intersect($id_list, $plain_res);
 }
 function createCategoriesSheet()
 {
     // remove root directory
     $base_level = $this->catalog_tree[1]['level'];
     $branches = array();
     $current_branch_id = 0;
     foreach ($this->catalog_tree as $key => $item) {
         if ($item['level'] == $base_level) {
             $current_branch_id++;
         }
         $item['level'] = $item['level'] - $base_level + 1;
         $branches[$current_branch_id][] = $item;
     }
     $this->total_branch_in_col = (int) (count($branches) / $this->total_cols);
     if ($this->total_branch_in_col == 0) {
         $this->total_branch_in_col = 1;
     }
     $this->width_col = (int) (100 / $this->total_cols);
     $pointer = 0;
     $result = "";
     $this->content_one_row = "";
     foreach ($branches as $branch) {
         foreach ($branch as $key => $item) {
             $this->category_level = $item['level'];
             $this->category_products = "";
             if ($this->show_products) {
                 $filter = new CProductListFilter();
                 $params = $filter->getProductListParamsObject();
                 $params->category_id = $item['id'];
                 $products_ids = Catalog::getProductListByFilter($params, true);
                 if (!empty($products_ids)) {
                     foreach ($products_ids as $product_key => $product_item) {
                         $this->current_product = new CProductInfo($product_item['product_id']);
                         $this->category_products .= $this->templateFiller->fill("Product");
                     }
                 }
             }
             $this->current_category = new CCategoryInfo($item['id']);
             $this->content_one_row .= $this->templateFiller->fill("Branch");
         }
         $pointer++;
         if ($pointer == $this->total_branch_in_col) {
             $result .= $this->templateFiller->fill("Item");
             $pointer = 0;
             $this->content_one_row = "";
         }
     }
     return $result;
 }