I
I
iminby2017-04-04 00:55:15
PHP
iminby, 2017-04-04 00:55:15

How to display an additional field created in the opencart product card?

There is a ready-made version ..
but it is only associated with the admin panel.
Everything is OK ..
the field is created .. The info is saved in the admin panel.
But in the product card, accordingly, it gives an error:
Notice: Undefined variable: short_description
As I understand it, because you need to look for all this happiness that is written there only for the admin folder,
add the whole thing to the controller in the catalog folder.
Is there anyone who can advise?
I've already rummaged through everything .. what is possible

READY OPTION, BUT I UNDERSTAND THIS IS ONLY A PART, which is for the admin panel

РАБОЧАЯ ИНСТРУКЦИЯ!!
1 В вашей базе данных создаем поле short_description в таблице oc_product_description, все атрибуты как и в description
я делал через phpmyadmin
2. файл admin/model/catalog/product.php
2а.
находим код
if (isset($data['product_store']))
18 строка
добавляем выше
foreach ($data['product_description'] as $language_id => $value) {
$this->db->query("UPDATE " . DB_PREFIX . "product_description
SET short_description = '" . $this->db->escape($value['short_description']) . "'
WHERE product_id = '" . (int)$product_id . "'
AND language_id = '" . (int)$language_id . "'");
}
//added template
находим второй раз
if (isset($data['product_store']))
153 строка стала
добавляем выше
foreach ($data['product_description'] as $language_id => $value) {
$this->db->query("UPDATE " . DB_PREFIX . "product_description
SET short_description = '" . $this->db->escape($value['short_description']) . "'
WHERE product_id = '" . (int)$product_id . "'
AND language_id = '" . (int)$language_id . "'");
}
//added template
2б.
находим
'meta_keyword' => $result['meta_keyword'],
теперь 450 строка
добавляем
'short_description' => $result['short_description'], //added template
3. файл admin/view/template/catalog/product_form.tpl
находим
<?php echo $entry_tag; ?>
88 строка
перед открывающемся слоем добавляем
Краткое описание:
<?php echo isset($product_description[$language['language_id']]) ? $product_description[$language['language_id']]['short_description'] : ''; ?>
Можно этот слой вставить куда вам удобнее, например под основное описание.
5. файл admin\controller\catalog\product.php
ищем код
$data['entry_description'] = $this->language->get('entry_description');
строка 542 добавляем ниже
$data['entry_short_description'] = $this->language->get('entry_short_description');
6. файл \admin\language\russian\catalog\product.php
ищем код
$_['entry_description'] = 'Описание';
добавляем ниже
$_['entry_short_description'] = 'Краткое описание';
7. все файлы в UTF-8 и заливаем
8. Долго мучался надо не забыть обновить кеш дополнений
Дополнения-дополнения-справа наверху кнопка обновить
У меня работает на 2.1.0.2

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question