Opencart: показ SKU в списке товаров (product/category) и на странице товара (product/product)

Opencart: показ SKU в списке товаров (product/category) и на странице товара (product/product) Выводим в шаблон SKU (артикул) товара

Для показа SKU (артикула) на странице списка товаров:

commit 1e06f21174b1fb07414cbe0cf2eeee0627b75e2f
Author: Ruslan Brest <rb@labtodo.com>
Date:   Mon Oct 17 13:24:33 2011 +0300
    [+] catalog: Добавлен показ SKU в списке товаров (product/category)
diff --git a/upload/catalog/controller/product/category.php b/upload/catalog/controller/product/category.php
index 500e6bb..1be14db 100644
--- a/upload/catalog/controller/product/category.php
+++ b/upload/catalog/controller/product/category.php
@@ -188,6 +188,7 @@ class ControllerProductCategory extends Controller {
 					'product_id'  => $result['product_id'],
 					'thumb'       => $image,
 					'name'        => $result['name'],
+					'sku'         => (empty($result['sku'])) ? '' : $this->language->get('text_sku') .' '. $result['sku'],
 					'description' => mb_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100, 'UTF-8') . '&hellip;',
 					'price'       => $price,
 					'special'     => $special,
diff --git a/upload/catalog/language/english/product/category.php b/upload/catalog/language/english/product/category.php
index def6f88..f3ddd08 100644
--- a/upload/catalog/language/english/product/category.php
+++ b/upload/catalog/language/english/product/category.php
@@ -7,6 +7,7 @@ $_['text_empty']        = 'There are no products to list in this category.';
 $_['text_quantity']     = 'Qty:';
 $_['text_manufacturer'] = 'Brand:';
 $_['text_model']        = 'Product Code:'; 
+$_['text_sku']          = 'SKU:';
 $_['text_points']       = 'Reward Points:'; 
 $_['text_price']        = 'Price:'; 
 $_['text_tax']          = 'Ex Tax:'; 
diff --git a/upload/catalog/language/russian/product/category.php b/upload/catalog/language/russian/product/category.php
index 762c91e..cfea2b9 100644
--- a/upload/catalog/language/russian/product/category.php
+++ b/upload/catalog/language/russian/product/category.php
@@ -7,6 +7,7 @@ $_['text_empty']        = 'В этой категории нет товаров.
 $_['text_quantity']     = 'Кол-во:';
 $_['text_manufacturer'] = 'Производитель:';
 $_['text_model']        = 'Модель:';
+$_['text_sku']          = 'SKU (Артикул):';
 $_['text_points']       = 'Бонусные баллы:';
 $_['text_price']        = 'Цена:';
 $_['text_tax']          = 'Без НДС:'; 
diff --git a/upload/catalog/view/theme/default/template/product/category.tpl b/upload/catalog/view/theme/default/template/product/category.tpl
index 37ff9c0..909edc4 100644
--- a/upload/catalog/view/theme/default/template/product/category.tpl
+++ b/upload/catalog/view/theme/default/template/product/category.tpl
@@ -72,7 +72,7 @@
       <?php if ($product['thumb']) { ?>
       <div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
       <?php } ?>
-      <div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></div>
+      <div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a>
<?php echo $product['sku']; ?></div>
       <div class="description"><?php echo $product['description']; ?></div>
       <?php if ($product['price']) { ?>
       <div class="price">

 

Для отображения sku (артикула) на страницы о товаре:

в файле catalog/controller/product/product.php

...
$this->document->setDescription($product_info['meta_description']);
$this->document->setKeywords($product_info['meta_keyword']);
$this->document->addLink($this->url->link('product/product', 'product_id=' . $this->request->get['product_id']), 'canonical');

$this->data['seo_h1'] = $product_info['seo_h1'];

$this->data['heading_title'] = $product_info['name'];

$this->data['text_select'] = $this->language->get('text_select');
$this->data['text_manufacturer'] = $this->language->get('text_manufacturer');
$this->data['text_model'] = $this->language->get('text_model');
$this->data['text_sku'] = $this->language->get('text_sku');
$this->data['text_reward'] = $this->language->get('text_reward');
$this->data['text_points'] = $this->language->get('text_points'); 
$this->data['text_discount'] = $this->language->get('text_discount');
$this->data['text_stock'] = $this->language->get('text_stock');
$this->data['text_price'] = $this->language->get('text_price');
$this->data['text_tax'] = $this->language->get('text_tax');
$this->data['text_discount'] = $this->language->get('text_discount');
$this->data['text_option'] = $this->language->get('text_option');
$this->data['text_qty'] = $this->language->get('text_qty');
$this->data['text_minimum'] = sprintf($this->language->get('text_minimum'), $product_info['minimum']);
$this->data['text_or'] = $this->language->get('text_or');
$this->data['text_write'] = $this->language->get('text_write');
$this->data['text_note'] = $this->language->get('text_note');
$this->data['text_share'] = $this->language->get('text_share');
$this->data['text_wait'] = $this->language->get('text_wait');
$this->data['text_tags'] = $this->language->get('text_tags');

$this->data['entry_name'] = $this->language->get('entry_name');
$this->data['entry_review'] = $this->language->get('entry_review');
$this->data['entry_rating'] = $this->language->get('entry_rating');
$this->data['entry_good'] = $this->language->get('entry_good');
$this->data['entry_bad'] = $this->language->get('entry_bad');
$this->data['entry_captcha'] = $this->language->get('entry_captcha');

$this->data['button_cart'] = $this->language->get('button_cart');
$this->data['button_wishlist'] = $this->language->get('button_wishlist');
$this->data['button_compare'] = $this->language->get('button_compare'); 
$this->data['button_upload'] = $this->language->get('button_upload');
$this->data['button_continue'] = $this->language->get('button_continue');

$this->load->model('catalog/review');

$this->data['tab_description'] = $this->language->get('tab_description');
$this->data['tab_attribute'] = $this->language->get('tab_attribute');
$this->data['tab_review'] = sprintf($this->language->get('tab_review'), $this->model_catalog_review->getTotalReviewsByProductId($this->request->get['product_id']));
$this->data['tab_related'] = $this->language->get('tab_related');

$this->data['product_id'] = $this->request->get['product_id'];
$this->data['manufacturer'] = $product_info['manufacturer'];
$this->data['manufacturers'] = $this->url->link('product/manufacturer/product', 'manufacturer_id=' . $product_info['manufacturer_id']);
$this->data['model'] = $product_info['model'];
$this->data['sku'] = $product_info['sku'];
$this->data['reward'] = $product_info['reward'];
$this->data['points'] = $product_info['points'];

if ($product_info['quantity'] <= 0) {
...

В языках catalog/language/russian/product/product.php:

$_['text_manufacturer'] = 'Производитель:';
$_['text_model']        = 'Модель:';
$_['text_sku']          = 'SKU (Артикул):';
$_['text_reward']       = 'Бонусные баллы:'; 
$_['text_points']       = 'Цена в бонусных баллах:';

В шаблоне страницы продукта (товара) - catalog/view/theme/default/template/product/product.tpl:

...
<span><?php echo $text_manufacturer; ?></span> <a href="<?php echo $manufacturers; ?>"><?php echo $manufacturer; ?></a><br />
        <?php } ?>
        <span><?php echo $text_model; ?></span> <?php echo $model; ?><br />
        <span><?php echo $text_sku; ?></span> <?php echo $sku; ?><br />
...
 
 

almix
Разработчик Loco, автор статей по веб-разработке на Yii, CodeIgniter, MODx и прочих инструментах. Создатель Team Sense.

Вы можете почитать все статьи от almix'а.



Другие статьи по этой теме:

Комментарии (2)     Подпишитесь на RSS комментариев к этой статье.

2 комментариев

#646
Alexander говорит:
September 20, 2012 at 07:09 pm
Большое спасибо за статью! 2 дня пытался сделать именно это, только с полем UPC.
#1412
Dea говорит:
August 21, 2015 at 10:12 pm

Добрый вечер!

Я сделала как вы написали но у меня исчезает артикул, есть FilterPro модуль 

Не подскажите что делать?