1. В catalog/model/catalog/products.php додаємо новий шматок в ~448 рядку
public function getProductsTags() {
$query = $this->db->query("SELECT DISTINCT tag FROM "
. DB_PREFIX
. "product_tags WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'"
);
return $query->rows;
}
2. Створюємо файл catalog/controller/module/tags.php
<?php
class ControllerModuleTags extends Controller
{
protected function index()
{
$this->language->load('module/tags');
$this->data['heading_title'] = $this->language->get('heading_title');
$this->load->model('catalog/product');
$this->load->model('tool/seo_url');
$this->data['text_tags'] = $this->language->get('text_tags');
$this->data['tags'] = array();
$results = $this->model_catalog_product->getProductsTags();
foreach ($results as $result) {
if ($result['tag']) {
$this->data['tags'][] = array(
'tag' => $result['tag'],
'href' => HTTP_SERVER . 'index.php?route=product/search&keyword=' . $result['tag']
);
}
}
$this->id = 'tags';
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/tags.tpl')) {
$this->template = $this->config->get('config_template') . '/template/module/tags.tpl';
} else {
$this->template = 'default/template/module/tags.tpl';
}
$this->render();
}
}
?>
3. Створюємо файл catalog/view/theme/default/template/module/tags.tpl
<?php echo $text_tags; ?>
<?php if ($tags) {?>
<?php foreach ($tags as $tag) { ?>
<?php echo $tag['tag']; ?>
<?php } ?>
<?php } ?>
4. Створюємо файл admin/view/template/module/tags.tpl
<?php echo $header; ?>
<?php if ($error_warning) { ?>
<?php echo $error_warning; ?>
<?php } ?>
<?php echo $heading_title; ?>
<?php echo $button_save; ?>
<?php echo $button_cancel; ?>
<?php echo $entry_position; ?>
<?php if ($tags_position == 'left') { ?>
<?php echo $text_left; ?>
<?php } else { ?>
<?php echo $text_left; ?>
<?php } ?>
<?php if ($tags_position == 'right') { ?>
<?php echo $text_right; ?>
<?php } else { ?>
<?php echo $text_right; ?>
<?php } ?>
<?php echo $entry_status; ?>
<?php if ($tags_status) { ?>
<?php echo $text_enabled; ?>
<?php echo $text_disabled; ?>
<?php } else { ?>
<?php echo $text_enabled; ?>
<?php echo $text_disabled; ?>
<?php } ?>
<?php echo $entry_sort_order; ?>
<?php echo $footer; ?>
5. Створюємо файл admin/controller/module/tags.php
<?php
class ControllerModuleTags extends Controller
{
private $error = array();
public function index()
{
$this->load->language('module/tags');
$this->document->title = $this->language->get('heading_title');
$this->load->model('setting/setting');
if (
($this->request->server['REQUEST_METHOD'] == 'POST')
&& ($this->validate())
) {
$this->model_setting_setting->editSetting('tags', $this->request->post);
$this->session->data['success'] = $this->language->get('text_success');
$this->redirect(HTTPS_SERVER . 'index.php?route=extension/module&token=' . $this->session->data['token']);
}
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['text_enabled'] = $this->language->get('text_enabled');
$this->data['text_disabled'] = $this->language->get('text_disabled');
$this->data['text_left'] = $this->language->get('text_left');
$this->data['text_right'] = $this->language->get('text_right');
$this->data['entry_position'] = $this->language->get('entry_position');
$this->data['entry_status'] = $this->language->get('entry_status');
$this->data['entry_sort_order'] = $this->language->get('entry_sort_order');
$this->data['button_save'] = $this->language->get('button_save');
$this->data['button_cancel'] = $this->language->get('button_cancel');
if (isset($this->error['warning'])) {
$this->data['error_warning'] = $this->error['warning'];
} else {
$this->data['error_warning'] = '';
}
$this->document->breadcrumbs = array();
$this->document->breadcrumbs[] = array(
'href' => HTTPS_SERVER . 'index.php?route=common/home&token=' . $this->session->data['token'],
'text' => $this->language->get('text_home'),
'separator' => FALSE
);
$this->document->breadcrumbs[] = array(
'href' => HTTPS_SERVER . 'index.php?route=extension/module&token=' . $this->session->data['token'],
'text' => $this->language->get('text_module'),
'separator' => ' :: '
);
$this->document->breadcrumbs[] = array(
'href' => HTTPS_SERVER . 'index.php?route=module/tags&token=' . $this->session->data['token'],
'text' => $this->language->get('heading_title'),
'separator' => ' :: '
);
$this->data['action'] = HTTPS_SERVER . 'index.php?route=module/tags&token=' . $this->session->data['token'];
$this->data['cancel'] = HTTPS_SERVER . 'index.php?route=extension/module&token=' . $this->session->data['token'];
if (isset($this->request->post['tags_position'])) {
$this->data['tags_position'] = $this->request->post['tags_position'];
} else {
$this->data['tags_position'] = $this->config->get('tags_position');
}
if (isset($this->request->post['tags_status'])) {
$this->data['tags_status'] = $this->request->post['tags_status'];
} else {
$this->data['tags_status'] = $this->config->get('tags_status');
}
if (isset($this->request->post['tags_sort_order'])) {
$this->data['tags_sort_order'] = $this->request->post['tags_sort_order'];
} else {
$this->data['tags_sort_order'] = $this->config->get('tags_sort_order');
}
$this->template = 'module/tags.tpl';
$this->children = array( 'common/header', 'common/footer' );
$this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
}
private function validate() {
if (!$this->user->hasPermission('modify', 'module/tags')) {
$this->error['warning'] = $this->language->get('error_permission');
}
if (!$this->error) {
return TRUE;
} else {
return FALSE;
}
}
}
?>
6. Створюємо файл admin/language/english/module/tags.php
<?php
// Heading $_['heading_title'] = 'Tags';
// Text $_['text_module'] = 'Modules';
$_['text_success'] = 'Success: You have modified module tags!';
$_['text_left'] = 'Left';
$_['text_right'] = 'Right';
// Entry $_['entry_position'] = 'Position:';
$_['entry_status'] = 'Status:';
$_['entry_sort_order'] = 'Sort Order:';
// Error $_['error_permission'] = 'Warning: You do not have permission to modify module tags!';
?>
7. Створюємо файл catalog/language/english/module/tags.php
<?php
// Heading $_['heading_title'] = 'heading_title';
$_['text_tags'] = 'tags';
?>