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

Дополнительные данные на странице товара


Webracer
 Share

Recommended Posts

Интересует где можно применить заполненные строки в редактировании товара: артикул (SKU), код (UPC), размещение?

Я прописал там разные цифры для теста, а они нигде не отобразились (я имею в виду страницу товара).

Что вообще означают эти поля, что туда писать и где это потом смотрть?

Link to comment
Share on other sites


Эти поля предназначены для внутреннего использования и не отображаются на странице товара в публичной части.

SKU - универсальный идентификатор товара (не обязательно артикул, это может быть составной идентификатор учитывающий характеристики товара, штрихкод и т.д.)

UPC - Штрихкод.

Размещение - Местоположение товара на адресном складе.

Link to comment
Share on other sites

Эти поля предназначены для внутреннего использования и не отображаются на странице товара в публичной части.

SKU - универсальный идентификатор товара (не обязательно артикул, это может быть составной идентификатор учитывающий характеристики товара, штрихкод и т.д.)

UPC - Штрихкод.

Размещение - Местоположение товара на адресном складе.

Понятно. Артикул товара (SKU) не помешал бы на странице товара, так как по артиклу удобнее искать товар. Ну да ладно, и без него обойдемся.
Link to comment
Share on other sites


Это поля для внутреннего пользования. Резервные, так сказать. Под любые нужды. Выводить их, в принципе, можно и на витрине, доработка там несложная. А так - для себя. Я вот, например SKU для себя использую по админке. Товар уникальный - ищу по артикулу. Удобно. В дальнейшем будем другие города подключать к магазину - расположение тоже пригодится. В ранних проектах я эти поля переименовывал под разное - сейчас поумнел - дополнительные создаю =) Спасибо форуму и его благородным обитателям.

Link to comment
Share on other sites

Так сделай вывод в шаблоне как считаеш нужным.

<?php echo $product_info['sku']; ?>

Получилось. А что написать в языковом файле? Такое?

$_['text_product_info']      = 'Артикул:';

Тогда по идее в шаблоне нужно вставить это:

<span><?php echo $text_product_info['sku']; ?></span> <?php echo $product_info['sku']; ?><br />

Но так оно не работает. Где ошибка?

Link to comment
Share on other sites


Добавить языковую переменную не достаточно, надо ещё в контроллере эту языковую переменную передать во вьювер...Полный маразм и раздражает не по детски, но так уж сделано...

В catalog\controller\product\product.php надо добавить

$this->data['text_product_info'] = $this->language->get('text_product_info');
и только потом в шаблоне

<span><?php echo $text_product_info; ?></span> <?php echo $product_info['sku']; ?><br />
Только логичнее text_sku, а не text_product_info
Link to comment
Share on other sites

  • 1 month later...

Вывожу вес товара и его габариты на страницу товара:

В шаблоне:

<span><?php echo $text_weight; ?></span> <?php echo $product_info['weight']; ?><br />
<span><?php echo $text_dimension; ?></span> <?php echo $product_info['length']; ?> x <?php echo $product_info['width']; ?> x <?php echo $product_info['height']; ?>

В контроллере:

$this->data['text_weight'] = $this->language->get('text_weight');
$this->data['text_dimension'] = $this->language->get('text_dimension');

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

Значения выводятся, но без указания в каких единицах (кг, г, м, см, мм). Как поправить?

Link to comment
Share on other sites


Посмотри, как они выводятся на странице сравнения товаров.

<tr>
        <td><?php echo $text_weight; ?></td>
        <?php foreach ($products as $product) { ?>
        <td><?php echo $products[$product['product_id']]['weight']; ?></td>
        <?php } ?>
      </tr>
      <tr>
        <td><?php echo $text_dimension; ?></td>
        <?php foreach ($products as $product) { ?>
        <td><?php echo $products[$product['product_id']]['length']; ?> x <?php echo $products[$product['product_id']]['width']; ?> x <?php echo $products[$product['product_id']]['height']; ?></td>
        <?php } ?>
      </tr>

Вот так

Link to comment
Share on other sites


Страница сравнения товаров - это же не только tpl. Вся предварительная кухня в контроллере.

Link to comment
Share on other sites


Страница сравнения товаров - это же не только tpl. Вся предварительная кухня в контроллере.

В контроллере:

$this->data['text_weight'] = $this->language->get('text_weight');
$this->data['text_dimension'] = $this->language->get('text_dimension');
Тут все совпадает с контроллером сравнения товаров.
Link to comment
Share on other sites


Смотри внимательней. Вот, например:

                                $this->data['products'][$product_id] = array(
                                        'product_id'   => $product_info['product_id'],
                                        'name'         => $product_info['name'],

                                        ...

                                        'reviews'      => sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']),
                                        'weight'       => $this->weight->format($product_info['weight'], $product_info['weight_class_id']),
                                        'length'       => $this->length->format($product_info['length'], $product_info['length_class_id']),
                                        'width'        => $this->length->format($product_info['width'], $product_info['length_class_id']),
                                        'height'       => $this->length->format($product_info['height'], $product_info['length_class_id']),
                                        'attribute'    => $attribute_data,
                                        'href'         => $this->url->link('product/product', 'product_id=' . $product_id),
                                        'remove'       => $this->url->link('product/product', 'product_id=' . $product_id)
                                );
Link to comment
Share on other sites


'weight'       => $this->weight->format($product_info['weight'], $product_info['weight_class_id']),
'length'       => $this->length->format($product_info['length'], $product_info['length_class_id']),
'width'        => $this->length->format($product_info['width'], $product_info['length_class_id']),
'height'       => $this->length->format($product_info['height'], $product_info['length_class_id']),

Это получается нужно еще добавить в контроллер товара. Только куда?

Link to comment
Share on other sites



diff --git a/upload/catalog/controller/product/product.php b/upload/catalog/controller/product/product.php

index 43f30de..c420a52 100644

--- a/upload/catalog/controller/product/product.php

+++ b/upload/catalog/controller/product/product.php

@@ -292,10 +292,14 @@ class ControllerProductProduct extends Controller {

$this->data['review_status'] = $this->config->get('config_review_status');

$this->data['reviews'] = sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']);

$this->data['rating'] = (int)$product_info['rating'];

$this->data['description'] = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8');

$this->data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($this->request->get['product_id']);

+ $this->data['weight'] = $this->weight->format($product_info['weight'], $product_info['weight_class_id']);

+ $this->data['length'] = $this->length->format($product_info['length'], $product_info['length_class_id']);

+ $this->data['width'] = $this->length->format($product_info['width'], $product_info['length_class_id']);

+ $this->data['height'] = $this->length->format($product_info['height'], $product_info['length_class_id']);

$this->data['products'] = array();

$results = $this->model_catalog_product->getProductRelated($this->request->get['product_id']);

diff --git a/upload/catalog/view/theme/default/template/product/product.tpl b/upload/catalog/view/theme/default/template/product/product.tpl

index 3810876..5793ff4 100644

--- a/upload/catalog/view/theme/default/template/product/product.tpl

+++ b/upload/catalog/view/theme/default/template/product/product.tpl

@@ -235,10 +235,15 @@

<?php } ?>

</div>

<div id="tab-description" class="tab-content"><?php echo $description; ?></div>

<?php if ($attribute_groups) { ?>

<div id="tab-attribute" class="tab-content">

+

+ <?php echo $weight; ?>

+ <?php echo $length; ?> x <?php echo $width; ?> x <?php echo $height; ?>

+

+

<table class="attribute">

<?php foreach ($attribute_groups as $attribute_group) { ?>

<thead>

<tr>

<td colspan="2"><?php echo $attribute_group['name']; ?></td>

Link to comment
Share on other sites


  • 4 weeks later...

У меня заработало, но только значения выводятся, без заголовков "Вес", "Габариты"

Как добавить заголовки?

А еще, можно убрать в габаритах лишние знаки после запятой? Хотя бы один знак только оставить.

Спасибо

Link to comment
Share on other sites


Как угодно. Если магазин - свой родной (для себя) и одноязыковый - дописать прям там же в TPL нужные слова.

Точность -- в валютах (настройки, локализация, валюты). Где-то там цифру 2 увидите, меняйте хоть на ноль.

Link to comment
Share on other sites


У меня там 0 и стоит, цены все без копеек.

Но я же не про цены, я про метрики "ширина-высота-длина"

Читать сложно - 12.00см x 16.00см x 6.00см

А так было бы красиво 12см x 16см x 6см

Link to comment
Share on other sites


А, пардон. Два файла, ищем функцию format внизу и меняем.

system/library/length.php

        public function format($value, $length_class_id, $decimal_point = '.', $thousand_point = ',') {
                if( 0 == $value ) return "";
                if (isset($this->lengths[$length_class_id])) {
                        return number_format($value, 0, $decimal_point, $thousand_point) . $this->lengths[$length_class_id]['unit'];
                } else {
                        return number_format($value, 0, $decimal_point, $thousand_point);
                }
        }

system/library/weight.php

        public function format($value, $weight_class_id, $decimal_point = '.', $thousand_point = ',') {
                if( 0 == $value ) return "";
                if (isset($this->weights[$weight_class_id])) {
                        return number_format($value, 0, $decimal_point, $thousand_point) . $this->weights[$weight_class_id]['unit'];
                } else {
                        return number_format($value, 0, $decimal_point, $thousand_point);
                }
        }
Link to comment
Share on other sites


Добавить языковую переменную не достаточно, надо ещё в контроллере эту языковую переменную передать во вьювер...Полный маразм и раздражает не по детски, но так уж сделано...

В catalog\controller\product\product.php надо добавить

$this->data['text_product_info'] = $this->language->get('text_product_info');
и только потом в шаблоне

<span><?php echo $text_product_info; ?></span> <?php echo $product_info['sku']; ?><br />
Только логичнее text_sku, а не text_product_info

Подскажите, как сделать, чтобы это работало в шаблоне header.tpl?

Например: надо в шапке вывести sku товара:

<div id="container">
  <div id="header">
...
  <div id="sku"><?php echo $text_sku; ?> - <?php echo $product_info['sku']; ?></div>
...
  </div>

</div>

Я понимаю, что в header.php надо сделать запрос к БД, но как именно не умею.

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.