Всем привет. Создал поле в phpMyAdmin с названием loc_use. Это поле для редактирования категорий. Данные из формы редактирования категорий записываются в базу, а вывести не получается. выдает ошибку
Undefined index: loc_use in /var/www/u1278903/public_html/opencart/catalog/controller/product/category.php on line 248
Fatal error: Uncaught Twig\Error\SyntaxError: Unknown "loc_use" tag in "default/template/product/category.twig" at line 27. in /var/www/u1278903/storage/vendor/twig/twig/src/Parser.php:175 Stack trace: #0 /var/www/u1278903/storage/vendor/twig/twig/src/Parser.php(98): Twig\Parser->subparse(NULL, false) #1 /var/www/u1278903/storage/vendor/twig/twig/src/Environment.php(563): Twig\Parser->parse(Object(Twig\TokenStream)) #2 /var/www/u1278903/storage/vendor/twig/twig/src/Environment.php(595): Twig\Environment->parse(Object(Twig\TokenStream)) #3 /var/www/u1278903/storage/vendor/twig/twig/src/Environment.php(408): Twig\Environment->compileSource(Object(Twig\Source)) #4 /var/www/u1278903/storage/vendor/twig/twig/src/Environment.php(381): Twig\Environment->loadClass('__TwigTemplate_...', 'default/templat...', NULL) #5 /var/www/u1278903/storage/vendor/twig/twig/src/Environment.php(359): Twig\Environment->loadTemplate('default/templat...') #6 /var/www/u1278903/storage/vendor/twig/twig/src/Environment.php(318): Twig\Environment->load( in /var/www/u1278903/storage/vendor/twig/twig/src/Parser.php on line 175
Файл admin/controller/catalog/category.php
if (isset($this->error['loc_use'])) {
$data['error_loc_use'] = $this->error['loc_use'];
} else {
$data['error_loc_use'] = array();
}
Файл admin/model/catalog/category.php
foreach ($data['category_description'] as $language_id => $value) {
$this->db->query("INSERT INTO " . DB_PREFIX . "category_description SET category_id = '" . (int)$category_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', description = '" . $this->db->escape($value['description']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_h1 = '" . $this->db->escape($value['meta_h1']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', loc_use = '" . $this->db->escape($value['loc_use']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
}
foreach ($data['category_description'] as $language_id => $value) {
$this->db->query("INSERT INTO " . DB_PREFIX . "category_description SET category_id = '" . (int)$category_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', description = '" . $this->db->escape($value['description']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_h1 = '" . $this->db->escape($value['meta_h1']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', loc_use = '" . $this->db->escape($value['loc_use']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
}
foreach ($query->rows as $result) {
$category_description_data[$result['language_id']] = array(
'name' => $result['name'],
'meta_title' => $result['meta_title'],
'meta_h1' => $result['meta_h1'],
'meta_description' => $result['meta_description'],
'meta_keyword' => $result['meta_keyword'],
'loc_use' => $result['loc_use'],
'description' => $result['description']
);
}
Файл admin/view/template/catalog/category_form.twig
<div class="form-group">
<label class="col-sm-2 control-label" for="input-loc_use{{ language.language_id }}">{{ entry_loc_use }}</label>
<div class="col-sm-10">
<textarea name="category_description[{{ language.language_id }}][loc_use]" placeholder="{{ entry_description }}" id="input-loc_use{{ language.language_id }}" data-toggle="summernote" data-lang="{{ summernote }}" class="form-control">{{ category_description[language.language_id] ? category_description[language.language_id].loc_use }}</textarea>
</div>
</div>
Файл catalog/controller/product/category.php
$data['loc_use'] = html_entity_decode($category_info['loc_use'], ENT_QUOTES, 'UTF-8');
$data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => utf8_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
'loc_use' => utf8_substr(trim(strip_tags(html_entity_decode($result['loc_use'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1,
'rating' => $result['rating'],
'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
);
Файл catalog/model/catalog/category.php я не изменял, т.к. не нашел схожих полей, ориентируюсь по meta_h1
файл catalog/view/theme/my_theme/template/product/category.twig
{% loc_use %}