Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Разный вид товара для разных категорий


Recommended Posts

Можно ли сделать разные дизайны страницы товара(ну где подробно описание товара,опции его и тд) для разных категорий?

Я как бы предполагаю что для каждого товара можно выбрать уникальный дизайн(на вкладке дизайн),но также замахаешься для каждого,вот еслибы для целой категории изменить сразу)

Link to comment
Share on other sites


разный фон я и сам себе сделать смогу)

мне нужно именно разный вид товара:

тоесть скажем в одной категории вид товара

Инфа

опции

описание

цена

В другой

Цена

опции

инфа

Вообщем разный product.tpl

Link to comment
Share on other sites


  • 2 weeks later...

Всё реально сделать.

Создаём дополнительное поле в БД для категорий, в которое будит заносится вид вывода товара.

При создании категории делаем выбор вида отображения.

И соответственно при выводе самого товара проверяем это поле и подключаем разный product.tpl

Link to comment
Share on other sites


  • 4 weeks later...

Вот простенький мануал для версии 1,5,1,3 как создать специфические шаблоны .tpl для категорий, товаров и т.д. !Шаблон зависит от файла .tpl в название которого вписывается id категории. Например для категории с id 55, название шаблона будет category_55.tpl (файл соответственно нужно поместить в папку /catalog/view/theme/default/template/product/category_55.tpl) и т.д. для других категорий. Далее делаем следующие изменения в файлах

  • Откройте catalog\controller\product\category.php
  • Загружем специфичский шаблон
    				// Найдите :
    				if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/category.tpl')) {
    					$this->template = $this->config->get('config_template') . '/template/product/category.tpl';
    				} else {
    					$this->template = 'default/template/product/category.tpl';
    				}	
    			// ЗАМЕНИТЕ :
    				if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/category_'.$category_id.'.tpl')) {
    					$this->template = $this->config->get('config_template') . '/template/product/category_'.$category_id.'.tpl';
    				} elseif (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/category.tpl')) {
    					$this->template = $this->config->get('config_template') . '/template/product/category.tpl';
    				} else {
    					$this->template = 'default/template/product/category.tpl';
    				}	
    
    :
  • Дальше в этом же файле
  • 			// Найдите :
    			$this->document->setTitle($category_info['name']);	
    		//ВЫШЕ ВСТАВьТЕ :
    			if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/stylesheet/category_'.$category_id.'.css')) {
    				$this->document->addStyle('catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/category_'.$category_id.'.css');
    			}	
    
Пример структуры
  • stylesheet/
    • stylesheet.css

      category_18.css

      product_17.css

      information_3.css

    template/
    • product/
    • category.tpl

      category_18.tpl

      product_17.tpl

  • information/
  • information.tpl

    information_3.tpl

category_product_information_spesific_template.xml

  • +1 2
Link to comment
Share on other sites


  • 1 year later...

Воспользовался данный решением для кастомизации категорий. Файл TPL поддягивает без проблем, а вот CSS отказывается, подскажите в чем может быть проблема? 

Link to comment
Share on other sites


  • 1 year later...

Вот простенький мануал для версии 1,5,1,3 как создать специфические шаблоны .tpl для категорий, товаров и т.д. !Шаблон зависит от файла .tpl в название которого вписывается id категории. Например для категории с id 55, название шаблона будет category_55.tpl (файл соответственно нужно поместить в папку /catalog/view/theme/default/template/product/category_55.tpl) и т.д. для других категорий. Далее делаем следующие изменения в файлах

  • Откройте catalog\controller\product\category.php
  • Загружем специфичский шаблон
    				// Найдите :
    				if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/category.tpl')) {
    					$this->template = $this->config->get('config_template') . '/template/product/category.tpl';
    				} else {
    					$this->template = 'default/template/product/category.tpl';
    				}	
    			// ЗАМЕНИТЕ :
    				if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/category_'.$category_id.'.tpl')) {
    					$this->template = $this->config->get('config_template') . '/template/product/category_'.$category_id.'.tpl';
    				} elseif (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/category.tpl')) {
    					$this->template = $this->config->get('config_template') . '/template/product/category.tpl';
    				} else {
    					$this->template = 'default/template/product/category.tpl';
    				}	
    
    :
  • Дальше в этом же файле
  • 			// Найдите :
    			$this->document->setTitle($category_info['name']);	
    		//ВЫШЕ ВСТАВьТЕ :
    			if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/stylesheet/category_'.$category_id.'.css')) {
    				$this->document->addStyle('catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/category_'.$category_id.'.css');
    			}	
    
Пример структуры
  • stylesheet/
  •  
    • stylesheet.css

      category_18.css

      product_17.css

      information_3.css

    template/
  •  
    • product/
    • category.tpl

      category_18.tpl

      product_17.tpl

  • information/
  • information.tpl

    information_3.tpl

 

Правильно я понял что этот метот позволяет в целом менять вид вывода категории или конкретного товара?

Если так, то как можно менять вид для всех карточек товаров, в определенной категории?

Спасибо!

Link to comment
Share on other sites


Это вообще то что нужно, даже выбор по пользователям есть, одним разом двух зайцев! огроменное спасибо за наводку!

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.