function assignCurrency() { $items = rad_instances::get('model_corecatalog_currency')->getItems(); $this->setVar('currency', $items); $this->setVar('currentCurrency', model_corecatalog_currcalc::getDefaultCurrencyId()); }
function __construct() { if ($this->getParamsObject()) { $params = $this->getParamsObject(); $this->_showPages = $params->_get('showpages', $this->_showPages, $this->getCurrentLangID()); $this->_treePages = $params->_get('treepages', $this->_treePages, $this->getCurrentLangID()); $this->_showArticles = $params->_get('showarticles', $this->_showArticles, $this->getCurrentLangID()); $this->_treeArticles = $params->_get('treearticles', $this->_treeArticles, $this->getCurrentLangID()); $this->_showNews = $params->_get('shownews', $this->_showNews, $this->getCurrentLangID()); $this->_treeNews = $params->_get('treenews', $this->_treeNews, $this->getCurrentLangID()); $this->_showCatalog = $params->_get('showcatalog', $this->_showCatalog); $this->_treeCatalog = $params->_get('treecatalog', $this->_treeCatalog, $this->getCurrentLangID()); $this->_exportSite = $params->_get('export', $this->_exportSite); $this->_shopName = $params->_get('shopname', $this->_shopName, $this->getCurrentLangID()); $this->_shopCompany = $params->_get('shopcompany', $this->_shopCompany, $this->getCurrentLangID()); $this->_shopAgency = $params->_get('shopagency', $this->_shopAgency, $this->getCurrentLangID()); $this->setVar('params', $params); } switch ($this->_exportSite) { case 'sitemap': if ($this->_showPages) { $pagesTree = rad_instances::get('model_coremenus_tree')->setState('active', 1)->setState('pid', $this->_treePages)->setState('lang', $this->getCurrentLangID())->getItems(true); if (!empty($pagesTree)) { rad_instances::get('model_corearticles_pages')->getPagesForTree($pagesTree, $this->getCurrentLangID()); $this->setVar('pagesTree', $pagesTree); } } if ($this->_showArticles) { $articlesTree = rad_instances::get('model_coremenus_tree')->setState('active', 1)->setState('pid', $this->_treeArticles)->setState('lang', $this->getCurrentLangID())->getItems(true); if (!empty($articlesTree)) { rad_instances::get('model_corearticles_articles')->getArticlessForTree($articlesTree, $this->getCurrentLangID()); $this->setVar('articlesTree', $articlesTree); } $this->setVar('articles', $articlesTree); } if ($this->_showNews) { $newsTree = rad_instances::get('model_coremenus_tree')->setState('active', 1)->setState('pid', $this->_treeNews)->setState('lang', $this->getCurrentLangID())->getItems(true); if (!empty($newsTree)) { rad_instances::get('model_corearticles_news')->getNewsForTree($newsTree, $this->getCurrentLangID()); $this->setVar('newsTree', $newsTree); } } //Show News if ($this->_showCatalog) { $catalogTree = rad_instances::get('model_coremenus_tree')->setState('active', 1)->setState('pid', $this->_treeCatalog)->setState('lang', $this->getCurrentLangID())->getItems(true); $modelCatalog = rad_instances::get('model_corecatalog_catalog')->setState('active', 1)->setState('join.mainimage', true)->setState('join.tree', true)->setState('lang', $this->getCurrentLangID())->setSTate('currency', model_corecatalog_currcalc::getDefaultCurrencyId()); $products = $modelCatalog->getItems(); if (!empty($products)) { foreach ($products as $product) { $this->_catRecursy($catalogTree, $product); } } $this->setVar('catalog', $catalogTree); } break; case 'yandex.yml': header("Content-Type: text/xml"); $this->setVar('nowdate', date("Y-m-d H:i")); $this->setVar('shop_name', mb_strlen($this->_shopName, 'utf-8') >= 20 ? mb_substr($this->_shopName, 0, 17, 'utf-8') . '...' : $this->_shopName); //Короткое название магазина — название, которое выводится в списке найденных на Яндекс. Маркете товаров. Оно не должно содержать более 20 символов. $this->setVar('shop_company', $this->_shopCompany); //Полное наименование компании, владеющей магазином. Не публикуется, используется для внутренней идентификации $this->setVar('shop_url', $this->config('url')); //URL главной страницы магазина. $this->setVar('shop_platform', 'Taberna'); //CMS, на основе которой работает магазин. $this->setVar('shop_version', rad_update::getInstance()->getCurrentVersion()); //Версия CMS. $this->setVar('shop_agency', $this->_shopAgency); //Наименование агентства, которое оказывает техническую поддержку магазину и отвечает за работоспособность сайта. $this->setVar('shop_email', $this->config('system.mail')); //Контактный адрес разработчиков CMS или агентства, осуществляющего техподдержку. // Show currencies $currencies = rad_instances::get('model_corecatalog_currency')->getItems(); $this->setVar('currencies', $currencies); // Show categries & offers $this->setVar('showCatalog', $this->_showCatalog); if ($this->_showCatalog) { $catalogTree = rad_instances::get('model_coremenus_tree')->setState('active', 1)->setState('pid', $this->_treeCatalog)->setState('lang', $this->getCurrentLangID())->getItems(true); $modelCatalog = rad_instances::get('model_corecatalog_catalog')->setState('active', 1)->setState('join.mainimage', true)->setState('join.tree', true)->setState('lang', $this->getCurrentLangID())->setSTate('currency', model_corecatalog_currcalc::getDefaultCurrencyId()); $products = $modelCatalog->getItems(); if (!empty($products)) { $modelCatalog->getValValues($products); foreach ($products as $product) { // Params if (count($product->type_vl_link)) { foreach ($product->type_vl_link as $tvlkey => $tvl) { if ($product->type_vl_link[$tvlkey]->vl_measurement_id) { $mesId = $product->type_vl_link[$tvlkey]->vl_measurement_id; $mes = new struct_corecatalog_measurement(array('ms_id' => $mesId)); $mes->load(); $product->type_vl_link[$tvlkey]->ms_value = trim($mes->ms_value); } } } // Pictures $model_images = rad_instances::get('model_core_image'); $model_images->setState('cat_id', $product->cat_id); $product->images_link = $model_images->getItems(); // Name if (mb_strlen($product->cat_name, 'utf-8') >= 255) { $product->cat_shortdesc = mb_substr($product->cat_name, 0, 252, 'utf-8') . '...'; } // Desctiption $product->cat_shortdesc = strip_tags($product->cat_shortdesc); if (mb_strlen($product->cat_shortdesc, 'utf-8') >= 512) { $product->cat_shortdesc = mb_substr($product->cat_shortdesc, 0, 509, 'utf-8') . '...'; } $this->_catRecursy($catalogTree, $product); } } $this->setVar('catalog', $catalogTree); } } }
protected function assignFilterPrice() { if (empty($this->_catIds)) { $cats = $this->_getCatsProducts(); if (!empty($cats)) { foreach ($cats as $id) { $this->_catIds[] = $id['cat_id']; } } } if (!empty($this->_catIds)) { $minmax = rad_instances::get('model_corecatalog_catalog')->setState('currency', model_corecatalog_currcalc::getDefaultCurrencyId())->setState('active', 1)->setState('tre_id', (int) $this->request($this->_getcat))->getMinMaxPrices(); $minmax['minprice'] = $minmax['minprice'] ? $minmax['minprice'] : 0; $minmax['maxprice'] = $minmax['maxprice'] ? $minmax['maxprice'] : 0; $this->setVar('prices', array('min' => $minmax['minprice'], 'max' => $minmax['maxprice'])); $this->_current['costfrom'] = $this->request('costfrom', $minmax['minprice']); if ($this->request('costfrom')) { $this->_currentFilter .= '&costfrom=' . $this->request('costfrom', $minmax['minprice']); } $this->_current['costto'] = $this->request('costto', $minmax['maxprice']); if ($this->request('costto')) { $this->_currentFilter .= '&costto=' . $this->request('costto', $minmax['maxprice']); } } }
/** * Assign the products */ function assignProducts() { $cat = (int) $this->request('cat', $this->_pid); $special_offer = (int) $this->request('so'); $order_by = $this->request('o'); $order_by_asc = (int) $this->request('asc', 2); if (!$cat and !$special_offer) { $this->securityHoleAlert(__FILE__, __LINE__, $this->getClassName()); return; } $this->setVar('itemsPerPageDefault', $this->_itemsPerPage); $this->_itemsPerPage = (int) $this->request('i', $this->_itemsPerPage); $this->setVar('itemsPerPage', $this->_itemsPerPage); $model = rad_instances::get('model_corecatalog_catalog'); if (!$special_offer) { $this->setVar('cat_id', $cat); $model->setState('tre_id', $cat); $tree_item = rad_instances::get('model_coremenus_tree')->getItem($cat); $this->setVar('tree_item', $tree_item); } else { $this->setVar('special_offer', $special_offer); $model->setState('special_offer', $special_offer); $model->setState('where_condition', ' 1 '); $this->addBC('so_id', $special_offer); $this->addBC('so_name', $this->lang('specialoffer' . $special_offer . '.catalog.title')); } $model->setState('active', 1); $model->setState('lang', $this->getCurrentLangID()); if ($this->request('filter')) { if ((int) $this->request('brand_id')) { if (strstr($this->request('brand_id'), ',')) { $brands = explode(',', $this->request('brand_id')); foreach ($brands as $keyBrand => $valBrand) { if (!(int) $valBrand) { unset($brands[$keyBrand]); } //if } //foreach } else { $brands = $this->request('brand_id', 0); } $model->setState('brand_id', $brands); $this->_currentFilter['brand_id'] = $brands; } if ($this->request('vv')) { $vv = array(); foreach ($this->request('vv') as $vlNameId => $vvValue) { if (!empty($vvValue)) { $vv[$vlNameId] = $vvValue; } } if (!empty($vv)) { $model->setState('val_values', $vv); $this->_currentFilter['vv'] = $vv; } } if ((double) $this->request('costfrom')) { $model->setState('cost.from', (double) $this->request('costfrom')); $this->_currentFilter['costfrom'] = (double) $this->request('costfrom'); $model->setState('currency', model_corecatalog_currcalc::getDefaultCurrencyId()); } if ((double) $this->request('costto')) { $model->setState('cost.to', (double) $this->request('costto')); $this->_currentFilter['costto'] = (double) $this->request('costto'); $model->setState('currency', model_corecatalog_currcalc::getDefaultCurrencyId()); } } $products_count = $model->getProductsListCount(); $this->setVar('products_count', $products_count); $p = (int) $this->request('p'); $page = $p ? $p : 0; $limit = $page * $this->_itemsPerPage . ',' . $this->_itemsPerPage; $model->setState('limit', $limit); $order = ' c.cat_position, '; switch ($this->request('o')) { case 'name': $order .= 'c.cat_name'; break; case 'cost': $order .= 'c.cat_cost*(cr.cur_cost/' . model_corecatalog_currcalc::currCours() . ')'; break; default: $order .= 'c.cat_name'; break; } $order .= $this->request('asc', true) ? ' ASC' : ' DESC'; $model->setState('order by', $order); $products = $model->getProductsList(true, $this->_ct_showing); if ($products_count) { $pages = div((int) $products_count, $this->_itemsPerPage); $pages += $products_count % $this->_itemsPerPage ? 1 : 0; $this->setVar('pages_count', $pages + 1); $this->setVar('page', $page + 1); $this->setVar('currPage', (int) $this->request('p', $page)); } else { $this->setVar('pages_count', 0); $this->setVar('page', 1); $this->setVar('currPage', (int) $this->request('p', 0)); } foreach ($products as $pkey => $product) { if (count($product->type_vl_link)) { foreach ($product->type_vl_link as $tvlkey => $tvl) { if ($product->type_vl_link[$tvlkey]->vl_measurement_id) { $mes_id = $product->type_vl_link[$tvlkey]->vl_measurement_id; $mes = new struct_corecatalog_measurement(array('ms_id' => $mes_id)); $mes->load(); $products[$pkey]->type_vl_link[$tvlkey]->ms_value = $mes->ms_value; } } } if ($this->config('partners.3dbin.license')) { rad_instances::get('model_corecatalog_3dimages')->assign3Dimages($products); } } $this->setVar('products', $products); }