Jump to content
Sign in to follow this  
Konlaz

Вывод категорий в карточке товара OpenCart 2.3

Recommended Posts

Отображает принадлежность товара к категориям в карточке товара.

Не знаю было ли что подобное на форуме наверняка наверное было, но на всякий случай выложу модификатор.

 

В строке <file path="catalog/view/theme/ВАША ТЕМА/template/product/product.tpl" error="log">

ВАША ТЕМА заменить на тему установленную у вас.

 

Заходим в модификаторы, нажимаем на + копируем, вставляем и сохраняем, делаем обновление и радуемся категориям в карточке товара.

 

 

<?xml version="1.0" encoding="utf-8"?>
<modification>
<code>Product Categories OpenCart 2.3</code>
<name>Product Categories OpenCart 2.3</name>
<version>2.3</version>
<author>konlaz@yandex.ru</author>

<file path="catalog/view/theme/ВАША ТЕМА/template/product/product.tpl" error="log">
<operation error="log">
<search><![CDATA[<?php echo $stock; ?></span></li>]]></search>
<add position="after"><![CDATA[<li class="p-brand">Категории товара: </span><?php foreach ($catprod as $catp) { ?> <a href="<?php echo $catp['href']; ?>"><?php echo $catp['name']; ?></a> \<?php } ?></li>]]></add>
</operation>
</file>

<file path="catalog/controller/product/product.php" error="log">
<operation error="log">
<search><![CDATA[if ($product_info) {]]></search>
<add position="before"><![CDATA[
    $this->load->model('catalog/category');
        $data['catprod'] = array();          
        $product_category = $this->model_catalog_product->getCategories($product_id);          
        foreach ($product_category as $prodcat) {
        $category_info = $this->model_catalog_category->getCategory($prodcat['category_id']);
        if ($category_info) {
             $data['catprod'][] = array(
             'name'     => $category_info['name'],
             'href'     => $this->url->link('product/category', 'path=' . $category_info['category_id'])
             );
        }
        } 
]]></add>
</operation>
</file>

</modification>

kategory.JPG

  • +1 1

Share this post


Link to post
Share on other sites

Не сработало! 
OCStore 2.3 + шаблон UniShop

 

Edited by oligarhist

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

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.