function getProductListByFilter($obj_params, $return_as = RETURN_AS_ID_LIST) { if (_is_a($obj_params, 'PRODUCT_LIST_PARAMS') == false) { die("ERROR: " . __CLASS__ . '::' . __FUNCTION__ . ' First param $obj_params must be an object of PRODUCT_LIST_PARAMS class.'); } $result = execQuery('SELECT_PRODUCT_LIST', $obj_params->getParams()); if ($return_as == RETURN_AS_ID_LIST) { return $result; } // return result as CProductInfo objects array $products_listing = array(); for ($i = 0; $i < sizeof($result); $i++) { $offset = 0; if ($obj_params->use_paginator) { $offset = modApiFunc('paginator', 'getCurrentPaginatorOffset'); } if (!is_numeric($offset)) { $offset = 0; } $product_info = new CProductInfo($result[$i]['product_id']); $product_info->setAdditionalProductTag('N', $i + 1 + $offset); array_push($products_listing, $product_info); } return $products_listing; }
/** * Returns the Product Listing view. * * @return string the Products List view. */ function output() { global $application; $this->__index = 0; // . $in_param = @func_get_arg(0); // - CProductSetTagSettings, if (_is_a($in_param, 'CProductSetTagSettings')) { $this->__tag_settings = $in_param; } else { // CProductSetTagSettings $this->__tag_settings = new CProductSetTagSettings(); } // hash $this->__filter_hash = $this->__tag_settings->filter->category_id; $this->__paginator_name = "Catalog_ProductSet_" . $this->__filter_hash; modAPIFunc('paginator', 'setCurrentPaginatorName', $this->__paginator_name); // - ( ) $this->registerAttributes(); // $this->__tmpl_filler = new TmplFiller($this->__tag_settings->template['Directory']); $cols = @func_get_arg(1); if ($cols !== false && is_numeric($cols)) { $this->columns = $cols; } else { $this->columns = 3; } // $this->__product_list_to_display = $this->getProductListToDisplay(); if (NULL == $this->__product_list_to_display || empty($this->__product_list_to_display)) { $retval = $this->__tmpl_filler->fill("", $this->__tag_settings->template['ContainerEmpty'], array(), true); } else { $retval = $this->__tmpl_filler->fill("", $this->__tag_settings->template['Container'], array(), true); } return $retval; }
/** * Returns the Product Listing view. * * @return string the Products List view. */ function output() { global $application; #define whether to output the view or not if ($this->NoView) { $application->outputTagErrors(true, __CLASS__, "Errors"); return ""; } else { $application->outputTagErrors(true, __CLASS__, "Warnings"); } // . $in_param = @func_get_arg(0); // - CProductListTagSettings, if (_is_a($in_param, 'CProductListTagSettings')) { $this->pl_tag_settings = $in_param; } else { // CProductListTagSettings $this->pl_tag_settings = new CProductListTagSettings(); // , if ($in_param === false || $in_param === null) { $this->pl_tag_settings->filter = modApiFunc('CProductListFilter', 'getProductListParamsObject'); // (default ) // - $this->pl_tag_settings->filter->use_paginator = true; } else { // , CProductListTagSettings, // Category Id, $category_id_to_read_from = $in_param; if (modApiFunc('Catalog', 'isCorrectCategoryId', $category_id_to_read_from)) { // , Show products from all subcategories $this->pl_tag_settings->product_list_filter_object->disableSynchronization(); $this->pl_tag_settings->product_list_filter_object->changeCurrentCategoryId($category_id_to_read_from); $this->pl_tag_settings->updateFilterParams(); } } } // $this->pagParam = $this->pl_tag_settings->filter->category_id; $category = new CCategoryInfo($this->pagParam); $category_status = $category->getCategoryTagValue('status'); if ($category_status == CATEGORY_STATUS_OFFLINE) { $request = new Request(); $request->setView('Index'); $application->redirect($request); return; } $this->pagName = modApiFunc('CProductListFilter', 'getMnfPaginatorName'); if (!$this->pagName) { $this->pagName = "Catalog_ProdsList_" . $this->pl_tag_settings->filter->category_id; } modAPIFunc('paginator', 'setCurrentPaginatorName', $this->getPagName()); // $this->registerAttributes(); $this->templateFiller = new TemplateFiller(); $this->templateFiller->setTemplate($this->pl_tag_settings->getTemplate()); $this->_product_form_action = getpageurl('CartContent'); $cols = @func_get_arg(1); if ($cols !== false && is_numeric($cols)) { $this->columns = $cols; } else { $this->columns = intval($application->getBlockOption($this->pl_tag_settings->getTemplate(), "Columns")); } // $this->pl = $this->getPL(); if (NULL == $this->pl) { $retval = $this->templateFiller->fill("ContainerEmpty"); } else { $retval = $this->templateFiller->fill("Container"); } return $retval; }