Коллеги, приветствую!
Ситуация:
OpenCart 3.0.3.7
- сделал OCMOD:
- в админке вкл/выкл бреды (производители):
- Catalog -> Manufacturers
Правки в файлах:
admin/controller/catalog/manufacturer.php
admin/model/catalog/manufacturer.php (+создание столбца в БД с именем: status)
admin/view/template/catalog/manufacturer_list.twig
admin/language/en-gb/catalog/manufacturer.php
admin/language/ru-ru/catalog/manufacturer.php
В итоге:
- работает всё прекрасно, вкл/выкл:
, но:
- почему-то не работает на фронте:
- выключенный бренд всё равно отображается
- захожу сюда:
Подскажите, пожалуйста, где нужно поправить?
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<name>[BE] Статус Enabled/Disabled Бренды</name>
<code>BE_StatusEnabledDisabledManufacturers_v100</code>
<version>1.0.0</version>
<author>MAEmelyanov</author>
<link>https://t.me/maemelyanov</link>
<!--
Description:
- Catalog -> Manufacturers
-->
<file path="admin/controller/catalog/manufacturer.php">
<operation>
<search>
<![CDATA[public function add() {]]>
</search>
<add position="before">
<![CDATA[public function enable() {
$this->load->language('catalog/manufacturer');
$this->document->setTitle($this->language->get('heading_title'));
$this->load->model('catalog/manufacturer');
if (isset($this->request->get['manufacturer_id']) && $this->validate()) {
$this->model_catalog_manufacturer->enableManufacturer($this->request->get['manufacturer_id']);
$this->session->data['success'] = $this->language->get('text_success');
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$this->response->redirect($this->url->link('catalog/manufacturer', 'user_token=' . $this->session->data['user_token'] . $url, true));
}
$this->getList();
}
public function disable() {
$this->load->language('catalog/manufacturer');
$this->document->setTitle($this->language->get('heading_title'));
$this->load->model('catalog/manufacturer');
if (isset($this->request->get['manufacturer_id']) && $this->validate()) {
$this->model_catalog_manufacturer->disableManufacturer($this->request->get['manufacturer_id']);
$this->session->data['success'] = $this->language->get('text_success');
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$this->response->redirect($this->url->link('catalog/manufacturer', 'user_token=' . $this->session->data['user_token'] . $url, true));
}
$this->getList();
}]]>
</add>
</operation>
<operation>
<search>
<![CDATA['edit' => $this->url->link('catalog/manufacturer/edit', 'user_token=' . $this->session->data['user_token'] . '&manufacturer_id=' . $result['manufacturer_id'] . $url, true)]]>
</search>
<add position="after">
<![CDATA[,'status' => $result['status'] ? $this->language->get('text_enabled') : $this->language->get('text_disabled'),
'enable' => $this->url->link('catalog/manufacturer/enable', 'user_token=' . $this->session->data['user_token'] . '&manufacturer_id=' . $result['manufacturer_id'] . $url, true),
'disable' => $this->url->link('catalog/manufacturer/disable', 'user_token=' . $this->session->data['user_token'] . '&manufacturer_id=' . $result['manufacturer_id'] . $url, true),
'enabled' => $result['status']]]>
</add>
</operation>
<operation>
<search>
<![CDATA[$data['sort_sort_order'] = $this->url->link('catalog/manufacturer', 'user_token=' . $this->session->data['user_token'] . '&sort=sort_order' . $url, true);]]>
</search>
<add position="after">
<![CDATA[$data['sort_status'] = $this->url->link('catalog/manufacturer', 'user_token=' . $this->session->data['user_token'] . '&sort=status' . $url, true);]]>
</add>
</operation>
<operation>
<search>
<![CDATA[protected function validateDelete() {]]>
</search>
<add position="before">
<![CDATA[ protected function validate() {
if (!$this->user->hasPermission('modify', 'catalog/manufacturer')) {
$this->error['warning'] = $this->language->get('error_permission');
}
return !$this->error;
}]]>
</add>
</operation>
</file>
<file path="admin/model/catalog/manufacturer.php">
<operation>
<search>
<![CDATA[public function addManufacturer($data) {]]>
</search>
<add position="before">
<![CDATA[
public function enableManufacturer($manufacturer_id) {
$this->db->query("UPDATE `" . DB_PREFIX . "manufacturer` SET `status` = '1' WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
}
public function disableManufacturer($manufacturer_id) {
$this->db->query("UPDATE `" . DB_PREFIX . "manufacturer` SET `status` = '0' WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
}]]>
</add>
</operation>
<operation>
<search><![CDATA[public function getManufacturers($data = array()) {]]></search>
<add position="after"><![CDATA[
$result_add_status = $this->db->query("SHOW COLUMNS FROM " . DB_PREFIX . "manufacturer LIKE 'status';");
if ($result_add_status->num_rows == 0) {
$this->db->query("ALTER TABLE " . DB_PREFIX . "manufacturer ADD COLUMN status TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' AFTER `sort_order` ;");
}
]]></add>
</operation>
</file>
<file path="admin/view/template/catalog/manufacturer_list.twig">
<operation>
<search>
<![CDATA[<td class="text-right">{{ column_action }}</td>]]>
</search>
<add position="before">
<![CDATA[<td class="text-left">{% if sort == 'status' %}
<a href="{{ sort_status }}" class="{{ order|lower }}">{{ entry_status }}</a>
{% else %}
<a href="{{ sort_status }}">{{ entry_status }}</a>
{% endif %}</td>]]>
</add>
</operation>
<operation>
<search>
<![CDATA[<td class="text-right"><a href="{{ manufacturer.edit }}" data-toggle="tooltip" title="{{ button_edit }}" class="btn btn-primary"><i class="fa fa-pencil"></i></a></td>]]>
</search>
<add position="before">
<![CDATA[<td class="text-left">{{ manufacturer.status }}</td>]]>
</add>
</operation>
<operation>
<search>
<![CDATA[<td class="text-right"><a href="{{ manufacturer.edit }}" data-toggle="tooltip" title="{{ button_edit }}" class="btn btn-primary"><i class="fa fa-pencil"></i></a></td>]]>
</search>
<add position="replace">
<![CDATA[<td class="text-right"><a href="{{ manufacturer.edit }}" data-toggle="tooltip" title="{{ button_edit }}" class="btn btn-primary"><i class="fa fa-pencil"></i></a>
{% if not manufacturer.enabled %}
<a href="{{ manufacturer.enable }}" data-toggle="tooltip" title="{{ button_enable }}" class="btn btn-success"><i class="fa fa-plus-circle"></i></a>
{% else %}
<a href="{{ manufacturer.disable }}" data-toggle="tooltip" title="{{ button_disable }}" class="btn btn-danger"><i class="fa fa-minus-circle"></i></a>
{% endif %}</td>]]>
</add>
</operation>
<operation>
<search>
<![CDATA[<td class="text-center" colspan="4">{{ text_no_results }}</td>]]>
</search>
<add position="replace">
<![CDATA[<td class="text-center" colspan="5">{{ text_no_results }}</td>]]>
</add>
</operation>
</file>
<file path="admin/language/en-gb/catalog/manufacturer.php">
<operation>
<search><![CDATA[$_['column_action'] = 'Action';]]></search>
<add position="after"><![CDATA[
$_['column_status'] = 'Status';
]]></add>
</operation>
<operation>
<search><![CDATA[$_['entry_type'] = 'Type';]]></search>
<add position="after"><![CDATA[
$_['entry_status'] = 'Status';
]]></add>
</operation>
</file>
<file path="admin/language/ru-ru/catalog/manufacturer.php">
<operation>
<search><![CDATA[$_['column_action'] = 'Действие';]]></search>
<add position="after"><![CDATA[
$_['column_status'] = 'Статус';
]]></add>
</operation>
<operation>
<search><![CDATA[$_['entry_type'] = 'Тип';]]></search>
<add position="after"><![CDATA[
$_['entry_status'] = 'Статус';
]]></add>
</operation>
</file>
</modification>