Мой вопрос: это мой первый проект для Open Cart, и я не знаю, насколько хорошо это MVCL)) Поэтому мне нужно написать модификацию ocmod для OpenCart 2.3.0.2 для добавления описания производителя на странице продукта. Ранее я нашел ocmod для добавления описания производителя на страницу производителя и отредактировал этот модуль для меня следующим кодом:
<?xml version="1.0" encoding="utf-8"?>
<modification>
<name>Manufacturer description</name>
<code>default</code>
<version>1.0</version>
<author></author>
<link></link>
<!-- code admin panel -->
<file path="admin/view/template/catalog/manufacturer_form.tpl">
<operation>
<search index="0"><![CDATA[<div class="form-group">]]></search>
<add position="before"><![CDATA[
<div class="form-group required">
<label class="col-sm-2 control-label" for="input-description">Описание</label>
<div class="col-sm-10">
<textarea name="descriptionmanufacturer" rows="5" placeholder="Описание" id="input-description" class="form-control"><?php echo isset($descriptionmanufacturer) ? $descriptionmanufacturer : ''; ?></textarea>
</div>
</div>
<script type="text/javascript">
$('#input-description').summernote({height: 100});
</script>
]]></add>
</operation>
</file>
<file path="admin/controller/catalog/manufacturer.php">
<operation>
<search><![CDATA[$this->load->model('setting/store');]]></search>
<add position="before"><![CDATA[
if (isset($this->request->post['descriptionmanufacturer'])) {
$data['descriptionmanufacturer'] = $this->request->post['descriptionmanufacturer'];
} elseif (!empty($manufacturer_info)) {
$data['descriptionmanufacturer'] = $manufacturer_info['descriptionm'];
} else {
$data['descriptionmanufacturer'] = '';
}
]]></add>
</operation>
</file>
<file path="admin/model/catalog/manufacturer.php">
<operation>
<search><![CDATA[if (isset($data['image'])) {]]></search>
<add position="before"><![CDATA[
if (isset($data['descriptionmanufacturer'])) {
$this->db->query("UPDATE " . DB_PREFIX . "manufacturer SET descriptionm = '" . $this->db->escape($data['descriptionmanufacturer']) . "' WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
}
]]></add>
</operation>
</file>
<!-- code admin panel -->
<!-- code view -->
<file path="catalog/controller/product/manufacturer.php">
<operation>
<search><![CDATA[$data['heading_title'] = $manufacturer_info['name'];]]></search>
<add position="before"><![CDATA[
$data['descriptionmanufacturer'] = html_entity_decode($manufacturer_info['descriptionm'], ENT_QUOTES, 'UTF-8');
if ($manufacturer_info['image']) {
$data['thumb'] = $this->model_tool_image->resize($manufacturer_info['image'], $this->config->get($this->config->get('config_theme') . '_image_category_width'), $this->config->get($this->config->get('config_theme') . '_image_category_height'));
} else {
$data['thumb'] = '';
}
]]></add>
</operation>
</file>
<file path="catalog/view/theme/*/template/product/manufacturer_info.tpl">
<operation>
<search><![CDATA[<h2><?php echo $heading_title; ?></h2>]]></search>
<add position="before"><![CDATA[
<?php if ($descriptionmanufacturer) { ?>
<div class="row">
<div class="col-sm-2"><img src="<?php echo $thumb; ?>" alt="<?php echo $heading_title; ?>" title="<?php echo $heading_title; ?>" class="img-thumbnail" /></div>
<div class="col-sm-10"><?php echo $descriptionmanufacturer; ?></div>
</div>
<br/>
<?php } ?>
]]></add>
</operation>
</file>
<!-- tab in product.tpl page -->
<file path="catalog/controller/product/product.php">
<operation>
<search><![CDATA[$this->load->model('catalog/manufacturer');]]></search>
<add position="after"><![CDATA[
$data['descriptionmanufacturer'] = html_entity_decode($manufacturer_info['descriptionm'], ENT_QUOTES, 'UTF-8');
if ($manufacturer_info['image']) {
$data['thumb'] = $this->model_tool_image->resize($manufacturer_info['image'], $this->config->get($this->config->get('config_theme') . '_image_category_width'), $this->config->get($this->config->get('config_theme') . '_image_category_height'));
} else {
$data['thumb'] = '';
}
]]></add>
</operation>
</file>
<file path="catalog/view/theme/*/template/product/product.tpl">
<operation>
<search><![CDATA[<li class="active"><a href="#tab-description" data-toggle="tab"><?php echo $tab_description; ?></a></li>]]></search>
<add position="after"><![CDATA[
<?php if ($descriptionmanufacturer) { ?>
<div class="row">
<div class="col-sm-10"><?php echo $descriptionmanufacturer; ?></div>
</div>
<br/>
<?php } ?>
]]></add>
</operation>
</file>
<!-- tab in product.tpl page -->
<!-- code voew -->
</modification>
И добавить столбец в базу данных:
ALTER TABLE `oc_manufacturer` ADD `descriptionm` TEXT NOT NULL AFTER `sort_order`;
Где я не так делаю ?? Это возвращает эту ошибку:
Notice: Undefined variable: manufacturer_info in C:\OpenServer\domains\apostle.loc\system\storage\modification\catalog\controller\product\product.php on line 72
Notice: Undefined variable: manufacturer_info in C:\OpenServer\domains\apostle.loc\system\storage\modification\catalog\controller\product\product.php on line 74
Но я не знаю, что написать в контроллере, я думаю. Пожалуйста помоги!))
Эта проблема решена! Я неправильно использовал место для добавления кода в контроллер product.php, теперь он выглядит правильно:
<file path="catalog/controller/product/product.php">
<operation>
<search><![CDATA[$data['heading_title'] = $product_info['name'];]]></search>
<add position="after"><![CDATA[
$manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($product_info['manufacturer_id']);
$data['descriptionmanufacturer'] = html_entity_decode($manufacturer_info['descriptionm'], ENT_QUOTES, 'UTF-8');
]]></add>
</operation>
</file>
Других решений пока нет …