Answer the question
In order to leave comments, you need to log in
How to add a field to category description in opencart 3?
Engine version 3.0.2.0
There is a need to add a second description for the category, conditionally let it be called description_short
So, I added a field to the database in the table oc_category_description "description_short" similar to "description"
Added to admin/views/template/category_form.twig
<div class="form-group">
<label class="col-sm-2 control-label" for="input-description-short{{ language.language_id }}">{{ entry_description_short }}</label>
<div class="col-sm-10">
<textarea name="category_description[{{ language.language_id }}][description_short]" placeholder="{{ entry_description }}" id="input-description-short{{ language.language_id }}" data-toggle="summernote" data-lang="{{ summernote }}" class="form-control">{{ category_description[language.language_id] ? category_description[language.language_id].description_short }}</textarea>
</div>
</div>
$data['description_short'] = html_entity_decode($category_info['description_short'], ENT_QUOTES, 'UTF-8');
// под подобной записью
// в методе addCategory в первом фориче и в методе editCaterogy соответственно, так же в первом фориче
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']) . "', description_short = '" . $this->db->escape($value['description_short']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
}
// editCategory
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']) . "', description_short = '" . $this->db->escape($value['description_short']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question