我的问题:这是我的第一个Open Cart项目,我不知道这个MVCL好))所以我需要为OpenCart 2.3.0.2编写ocmod修改,以便在产品页面中添加制造商描述。早期我发现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
但我不知道我认为在控制器中写什么。请帮忙!))
答案 0 :(得分:0)
这个问题解决了!我错误地使用地方在控制器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>