alexandr12345

Новичок
  • Публикаций

    7
  • Зарегистрирован

  • Посещение

Репутация

0 Обычный

Информация о alexandr12345

  • Звание
    Новичок
  1. <?php class ControllerProductCategory extends Controller { public function index() { $this->load->language('product/category'); $this->load->model('catalog/category'); $this->load->model('catalog/product'); $this->load->model('catalog/designer'); $this->load->model('catalog/inzhsystem'); $this->load->model('tool/image'); if (isset($this->request->get['filter'])) { $filter = $this->request->get['filter']; } else { $filter = ''; } if (isset($this->request->get['sort'])) { $sort = $this->request->get['sort']; } else { $sort = 'p.sort_order'; } if (isset($this->request->get['order'])) { $order = $this->request->get['order']; } else { $order = 'ASC'; } if (isset($this->request->get['page'])) { $page = $this->request->get['page']; } else { $page = 1; } if (isset($this->request->get['limit'])) { $limit = (int)$this->request->get['limit']; } else { $limit = $this->config->get('config_product_limit'); } $data['breadcrumbs'] = array(); $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home') ); if (isset($this->request->get['path'])) { $url = ''; if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $path = ''; $parts = explode('_', (string)$this->request->get['path']); $category_id = (int)array_pop($parts); foreach ($parts as $path_id) { if (!$path) { $path = (int)$path_id; } else { $path .= '_' . (int)$path_id; } $category_info = $this->model_catalog_category->getCategory($path_id); if ($category_info) { $data['breadcrumbs'][] = array( 'text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $path . $url) ); } } $cat_level = count($parts); } else { $category_id = 0; $cat_level = 0; } $category_info = $this->model_catalog_category->getCategory($category_id); if ($category_info) { if ($category_info['meta_title']) { $this->document->setTitle($category_info['meta_title']); } else { $this->document->setTitle($category_info['name']); } $this->document->setDescription($category_info['meta_description']); $this->document->setKeywords($category_info['meta_keyword']); if ($category_info['meta_h1']) { $data['heading_title'] = $category_info['meta_h1']; } else { $data['heading_title'] = $category_info['name']; } if ($category_info['clear'] == 1 && (preg_match("/^\/[0-9a-z_\-]*\/$/i", $_SERVER['REQUEST_URI']))) { $clear = 1; $data['clear'] = $clear; $GLOBALS['category_clear'] = $clear; $product_total = 0; } else { $clear = null; $GLOBALS['category_clear'] = $clear; $data['clear'] = $clear; } $data['text_refine'] = $this->language->get('text_refine'); $data['text_empty'] = $this->language->get('text_empty'); $data['text_quantity'] = $this->language->get('text_quantity'); $data['text_manufacturer'] = $this->language->get('text_manufacturer'); $data['text_model'] = $this->language->get('text_model'); $data['text_designer'] = $this->language->get('text_designer'); $data['text_price'] = $this->language->get('text_price'); $data['text_tax'] = $this->language->get('text_tax'); $data['text_points'] = $this->language->get('text_points'); $data['text_compare'] = sprintf($this->language->get('text_compare'), (isset($this->session->data['compare']) ? count($this->session->data['compare']) : 0)); $data['text_sort'] = $this->language->get('text_sort'); $data['text_limit'] = $this->language->get('text_limit'); $data['button_cart'] = $this->language->get('button_cart'); $data['button_wishlist'] = $this->language->get('button_wishlist'); $data['button_compare'] = $this->language->get('button_compare'); $data['button_continue'] = $this->language->get('button_continue'); $data['button_list'] = $this->language->get('button_list'); $data['button_grid'] = $this->language->get('button_grid'); $data['text_new'] = $this->language->get('text_new'); $data['text_quickview'] = $this->language->get('text_quickview'); $data['page_title'] = $this->language->get('page_title'); // Set the last category breadcrumb $data['breadcrumbs'][] = array( 'text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path']) ); if ($category_info['image']) { $data['thumb'] = $this->model_tool_image->resize($category_info['image'], $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height')); } else { $data['thumb'] = ''; } $data['description'] = html_entity_decode($category_info['description'], ENT_QUOTES, 'UTF-8'); $data['compare'] = $this->url->link('product/compare'); $url = ''; if (isset($this->request->get['filter'])) { $url .= '&filter=' . $this->request->get['filter']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['designer'] = $this->model_catalog_designer->getDesigner($category_info['designer_id']); $inzh_systems_data_sub = $this->model_catalog_inzhsystem->getInzhSystems($category_info['category_id']); foreach ($inzh_systems_data_sub as $inzh_system_sub) { foreach ($inzh_system_sub as $inzh_system_sub_id) { $related_info = $this->model_catalog_inzhsystem->getInzhSystem($inzh_system_sub_id); if ($related_info) { $data['inzh_systems_sub'][] = array( 'image' => $related_info['image'], 'name' => $related_info['name'], 'url' => $related_info['url'] ); } } } if ($clear != 1) { $data['products_sub'] = array(); $filter_data_sub = array( 'filter_category_id' => $category_id, 'filter_filter' => $filter, 'sort' => $sort, 'order' => $order, 'start' => ($page - 1) * $limit, 'limit' => $limit ); $product_total = $this->model_catalog_product->getTotalProducts($filter_data_sub); $results_sub = $this->model_catalog_product->getProducts($filter_data_sub); foreach ($results_sub as $result_sub) { if ($result_sub['image']) { $image = $this->model_tool_image->resize($result_sub['image'], 0, $this->config->get('config_image_product_height')); } else { $image = $this->model_tool_image->resize('placeholder.png', 0, $this->config->get('config_image_product_height')); } if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) { $price = $this->currency->format($this->tax->calculate($result_sub['price'], $result_sub['tax_class_id'], $this->config->get('config_tax'))); } else { $price = false; } if ((float)$result_sub['special']) { $special = $this->currency->format($this->tax->calculate($result_sub['special'], $result_sub['tax_class_id'], $this->config->get('config_tax'))); } else { $special = false; } if ($this->config->get('config_tax')) { $tax = $this->currency->format((float)$result_sub['special'] ? $result_sub['special'] : $result_sub['price']); } else { $tax = false; } if ($this->config->get('config_review_status')) { $rating = (int)$result_sub['rating']; } else { $rating = false; } $data['products_sub'][] = array( 'product_id' => $result_sub['product_id'], 'thumb' => $image, 'name' => $result_sub['name'], 'model' => $result_sub['model'], 'description' => utf8_substr(strip_tags(html_entity_decode($result_sub['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..', 'price' => $price, 'special' => $special, 'minimum' => $result_sub['minimum'] > 0 ? $result_sub['minimum'] : 1, 'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result_sub['product_id'] . $url) ); } $data['categories'] = array(); $categories = $this->model_catalog_category->getCategories($category_id); foreach ($categories as $category) { $products_data = array(); $inzh_systems_info = array(); $filt_data = array( 'filter_category_id' => $category['category_id'], 'filter_filter' => $filter, 'sort' => $sort, 'order' => $order, 'start' => ($page - 1) * $limit, 'limit' => 500 ); //$product_total = $this->model_catalog_product->getTotalProducts($filt_data); $results = $this->model_catalog_product->getProducts($filt_data); foreach ($results as $result) { if ($result['image']) { $image = $this->model_tool_image->resize($result['image'], 0, $this->config->get('config_image_product_height')); } else { $image = $this->model_tool_image->resize('placeholder.png', $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')); } if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) { $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))); } else { $price = false; } if ((float)$result['special']) { $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax'))); } else { $special = false; } if ($this->config->get('config_tax')) { $tax = $this->currency->format((float)$result['special'] ? $result['special'] : $result['price']); } else { $tax = false; } if ($this->config->get('config_review_status')) { $rating = (int)$result['rating']; } else { $rating = false; } $products_data[] = array( 'product_id' => $result['product_id'], 'thumb' => $image, 'name' => $result['name'], 'model' => $result['model'], 'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 250, $this->config->get('config_product_description_length')) . '..', 'price' => $price, 'special' => $special, 'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1, 'startdate' => $result['date_available'], 'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url) ); } $data['designer_data'] = array(); $designer_data = $this->model_catalog_designer->getDesigner($category['designer_id']); if (!$designer_data) { $designer_data['name'] = ''; $designer_data['image'] = ''; } $inzh_systems_data = $this->model_catalog_inzhsystem->getInzhSystems($category['category_id']); foreach ($inzh_systems_data as $inzh_system) { foreach ($inzh_system as $inzh_system_id) { $related_info = $this->model_catalog_inzhsystem->getInzhSystem($inzh_system_id); if ($related_info) { $inzh_systems_info[] = array( 'image' => $related_info['image'], 'name' => $related_info['name'], 'url' => $related_info['url'] ); } } } $data['categories'][] = array( 'category_id' => $category['category_id'], 'thumb' => $category['image'], 'products' => $products_data, 'designer_name' => $designer_data['name'], 'designer_image' => $designer_data['image'], 'inzh_systems' => $inzh_systems_info, 'name' => $category['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''), 'description' => strip_tags(html_entity_decode($category['description'], ENT_QUOTES, 'UTF-8')), 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $category['category_id'] . $url) ); } } $url = ''; if (isset($this->request->get['filter'])) { $url .= '&filter=' . $this->request->get['filter']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['sorts'] = array(); $data['sorts'][] = array( 'text' => $this->language->get('text_default'), 'value' => 'p.sort_order-ASC', 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.sort_order&order=ASC' . $url) ); $data['sorts'][] = array( 'text' => $this->language->get('text_name_asc'), 'value' => 'pd.name-ASC', 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=pd.name&order=ASC' . $url) ); $data['sorts'][] = array( 'text' => $this->language->get('text_name_desc'), 'value' => 'pd.name-DESC', 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=pd.name&order=DESC' . $url) ); $data['sorts'][] = array( 'text' => $this->language->get('text_price_asc'), 'value' => 'p.price-ASC', 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.price&order=ASC' . $url) ); $data['sorts'][] = array( 'text' => $this->language->get('text_price_desc'), 'value' => 'p.price-DESC', 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.price&order=DESC' . $url) ); if ($this->config->get('config_review_status')) { $data['sorts'][] = array( 'text' => $this->language->get('text_rating_desc'), 'value' => 'rating-DESC', 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=rating&order=DESC' . $url) ); $data['sorts'][] = array( 'text' => $this->language->get('text_rating_asc'), 'value' => 'rating-ASC', 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=rating&order=ASC' . $url) ); } $data['sorts'][] = array( 'text' => $this->language->get('text_model_asc'), 'value' => 'p.model-ASC', 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.model&order=ASC' . $url) ); $data['sorts'][] = array( 'text' => $this->language->get('text_model_desc'), 'value' => 'p.model-DESC', 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.model&order=DESC' . $url) ); $url = ''; if (isset($this->request->get['filter'])) { $url .= '&filter=' . $this->request->get['filter']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } $data['limits'] = array(); $limits = array_unique(array($this->config->get('config_product_limit'), 25, 50, 75, 100)); sort($limits); foreach($limits as $value) { $data['limits'][] = array( 'text' => $value, 'value' => $value, 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url . '&limit=' . $value) ); } $url = ''; if (isset($this->request->get['filter'])) { $url .= '&filter=' . $this->request->get['filter']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $pagination = new Pagination(); $pagination->total = $product_total; $pagination->page = $page; $pagination->limit = $limit; $pagination->url = $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url . '&page={page}'); $data['pagination'] = $pagination->render(); $data['results'] = sprintf($this->language->get('text_pagination'), ($product_total) ? (($page - 1) * $limit) + 1 : 0, ((($page - 1) * $limit) > ($product_total - $limit)) ? $product_total : ((($page - 1) * $limit) + $limit), $product_total, ceil($product_total / $limit)); // http://googlewebmastercentral.blogspot.com/2011/09/pagination-with-relnext-and-relprev.html if ($page == 1) { $this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'], 'SSL'), 'canonical'); } elseif ($page == 2) { $this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'], 'SSL'), 'prev'); } else { $this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. ($page - 1), 'SSL'), 'prev'); } if ($limit && ceil($product_total / $limit) > $page) { $this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. ($page + 1), 'SSL'), 'next'); } $data['sort'] = $sort; $data['order'] = $order; $data['limit'] = $limit; $data['continue'] = $this->url->link('common/home'); $data['column_left'] = $this->load->controller('common/column_left'); $data['column_right'] = $this->load->controller('common/column_right'); $data['content_top'] = $this->load->controller('common/content_top'); $data['content_bottom'] = $this->load->controller('common/content_bottom'); $data['footer'] = $this->load->controller('common/footer'); $data['header'] = $this->load->controller('common/header'); if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/category.tpl')) { $this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/product/category.tpl', $data)); } else { $this->response->setOutput($this->load->view('default/template/product/category.tpl', $data)); } } else { $url = ''; if (isset($this->request->get['path'])) { $url .= '&path=' . $this->request->get['path']; } if (isset($this->request->get['filter'])) { $url .= '&filter=' . $this->request->get['filter']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_error'), 'href' => $this->url->link('product/category', $url) ); $this->document->setTitle($this->language->get('text_error')); $data['heading_title'] = $this->language->get('text_error'); $data['text_error'] = $this->language->get('text_error'); $data['button_continue'] = $this->language->get('button_continue'); $data['continue'] = $this->url->link('common/home'); $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found'); $data['column_left'] = $this->load->controller('common/column_left'); $data['column_right'] = $this->load->controller('common/column_right'); $data['content_top'] = $this->load->controller('common/content_top'); $data['content_bottom'] = $this->load->controller('common/content_bottom'); $data['footer'] = $this->load->controller('common/footer'); $data['header'] = $this->load->controller('common/header'); if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) { $this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/error/not_found.tpl', $data)); } else { $this->response->setOutput($this->load->view('default/template/error/not_found.tpl', $data)); } } } } вот весь файл, буду благодарен, если подскажите.
  2. $data['products_sub'][] = array( 'product_id' => $result_sub['product_id'], 'thumb' => $image, 'name' => $result_sub['name'], 'model' => $result_sub['model'], 'description' => utf8_substr(strip_tags(html_entity_decode($result_sub['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..', 'price' => $price, 'special' => $special, 'minimum' => $result_sub['minimum'] > 0 ? $result_sub['minimum'] : 1, 'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result_sub['product_id'] . $url) ); Вот такой текст есть там, тут менять?
  3. Я думал в шаблоне прописать "типо брать товар из категории 238" и все.
  4. Почему это говно? Просто на родительской категории более 10000 товаров, если я их всех вывожу, то у меня страница грузится долго хоть и есть пагинация. Если бы для данной категории я просто поставил вывод товаров из категории 238, то у меня бы выводились нужные товары. Почему это не правильно?
  5. Добрый день! Необходимо в определенную категорию вывести товары, которые состоят в другой категории. Данный шаблон лучше реализовать на ID категории. То есть, для каждой категории на сайте я могу установить персонализированный шаблон и вот для одной категории мне нужно прописать, чтобы в этой категории выводились все товары из категории №5 например. Знаю, что можно просто добавить все нужные товары в эту категорию и ничего не мудрить с шаблонами, но нужно именно так, чтобы в эту категорию брались товары из другой. Вот существующий шаблон. Айди нужно категории 238. <?php $config = $this->registry->get('config'); ?> <?php $id_slider = '111'; ?> <?php echo $header; ?> <ul class="breadcrumb"> <?php foreach ($breadcrumbs as $i=> $breadcrumb) { ?> <li><?php if($i+1<count($breadcrumbs)) { ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a> <?php } else { ?><?php echo $breadcrumb['text']; ?><?php } ?></li> <?php } ?> </ul> <?php echo $content_top; ?> <div class="container category-page parket"> <div class="row"><?php echo $column_left; ?> <?php if ($column_left && $column_right) { ?> <?php $class = 'col-sm-6'; ?> <?php } elseif ($column_left || $column_right) { ?> <?php $class = 'col-sm-9'; ?> <?php } else { ?> <?php $class = 'col-sm-12'; ?> <?php } ?> <div id="content" class="<?php echo $class; ?>"> <div class="cattitle"> <h1><?php echo $heading_title; ?></h1> <div class="blocks hidden-xs"> <?php } ?> </div> <?php } ?> </div> </div> <?php if ($products_sub) { ?> <div class="product-grid"> <div class="row flex-container"> <?php foreach ($products_sub as $product_sub) { ?> <div class="col-xs-12 col-sm-25 product-container"> <div class="product-block"> <?php if ($product_sub['thumb']) { ?> <div class="image"> <a href="<?php echo $product_sub['href']; ?>" style="background:transparent; box-shadow:none;"> <img src="<?php echo $product_sub['thumb']; ?>" title="<?php echo $product_sub['name']; ?>" alt="<?php echo $product_sub['name']; ?>" /> <div class="more">Посмотреть все цвета и варианты</div> </a> </div> <?php } ?> <span class="product-name hidden"><?php echo $product_sub['name']; ?></span> <div class="prod-model"> <a href="<?php echo $product_sub['href']; ?>" style="background:transparent; box-shadow:none;"><span class="model"><?php echo $product_sub['model']; ?></span></a> </div> <?php if ($product_sub['price']) { ?> <div class="price"> <span class="button typecatalog modal-raschet">Рассчитать</span> </div> <?php } ?> </div> </div> <?php } ?> </div> </div> <div class="row"> <div class="text-center"><?php echo $pagination; ?></div> </div> <?php } ?> <?php if (!$categories && !$products_sub) { ?> <p><?php echo $text_empty; ?></p> <div class="buttons"> <div class="pull-right"><a href="<?php echo $continue; ?>" class="btn btn-primary"><?php echo $button_continue; ?></a></div> </div> <?php } ?> </div> <div class="clearfix"></div> <?php if ($description) { ?> <div class="description" <?php if ($designer || (isset($inzh_systems_sub) && ($inzh_systems_sub))) echo 'style="text-align: justify; padding: 0 2em 0 1em;"'; ?>> <p><?php echo $description; ?></p> </div> <?php } ?> <?php echo $column_right; ?></div> </div> <?php echo $footer; ?> Я буду очень признателен за помощь!!!
  6. Mega Filter PLUS [powered by Mega Filter PRO][2.x]

    Здравствуйте! Возникла одна сложность в фильтре Mega Filter Pro Plus. В фильтре есть возможность реализовывать СЕО чпу урлы для каких-либо атрибутов фильтрации, все круто и удобно, но у меня возникла проблема. Сейчас на сайте насчитывается уже более 10000 товаров и на главной странице категорий, например /dveri/ стало огромное количество товаров и она очень долго грузится (товары отображаются списком с картинками). Нашел для себя решение данной проблемы: переделать шаблон отображения товаров на главной странице, чтобы показывались просто категории, статически, как мне нужно сам пропишу в дискрипшен, без фильтра. Типо: категории - все фабрики, все инженерные системы и тд, а не весь товар списком с возможностью фильтрации. Дак вот, я обыскал все, что можно, не могу разобраться, как чпу ссылки в фильтре унаследывают шаблон от главной категории, где это прописано и как изменить. Также, одним способом получилось отключить весь контент на главной странице категории, но не могу отключить фильтр, то есть по факту страница при открытии что-то там думает, в фильтре появляются все варианты как раньше изменений аттрибутов, но товара нету, и из-за этого страница грузится секунд 20... Нужно или как-то на главной странице убрать фильтр и переделать шаблон, чтобы товары не отображались, либо найти, как изменить унаследование шаблона для отображении товара в фильтре. Буду очень благодарен за любую информацию, двое суток не могу разобраться. Хотя-бы скажите, в какую сторону двигаться... Спасибо большое.