M
M
Mikhail Zavalko2017-10-15 15:11:14
PHP
Mikhail Zavalko, 2017-10-15 15:11:14

ocmod module to display manufacturer's description?

Hi all! Such a question, I’ll fight right away, this is the first project on opencart, I ask you not to immediately throw pissing rags)): it means that you need to display the manufacturer’s description in the tab on the product page, I found it seems like a suitable module that adds a description to the manufacturers in the admin panel, and displays this description on manufacturer's page, but I need to get out a little different. The module code is here:

<?xml version="1.0" encoding="utf-8"?>
<modification>
    <name>Manufacturer description</name>
    <code>default</code>
    <version>1.0</version>
    <author></author>
    <link></link>
    <!-- код админки -->
    <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="description" rows="5" placeholder="Описание" id="input-description" class="form-control"><?php echo isset($description) ? $description : ''; ?></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['description'])) {
            $data['description'] = $this->request->post['description'];
        } elseif (!empty($manufacturer_info)) {
            $data['description'] = $manufacturer_info['descriptionm'];
        } else {
            $data['description'] = '';
        }
            ]]></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['description'])) {
            $this->db->query("UPDATE " . DB_PREFIX . "manufacturer SET descriptionm = '" . $this->db->escape($data['description']) . "' WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
        }
            ]]></add>
  </operation>
    </file>
    <!-- код админки -->

    <!-- код вывода -->
    <file path="catalog/controller/product/manufacturer.php">
  <operation>
      <search><![CDATA[$data['heading_title'] = $manufacturer_info['name'];]]></search>
      <add position="before"><![CDATA[
            $data['description'] = 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 ($description) { ?>
        <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 $description; ?></div>
      </div>
      &nbsp;<br/>&nbsp;
        <?php } ?>
            ]]></add>
  </operation>
    </file>
    <!-- код вывода -->
</modification>

I myself tried unsuccessfully to display it in product.tpl, but I understand that I’m not doing everything right, so when adding <?php echo $description; ?> an error pops up in product.tpl: Notice: Use of undefined constant manufacturer - assumed 'manufacturer' in domain\system\storage\modification\catalog\view\theme\THEMENAME\template\product\product.tpl on line
880 that the problem is that I didn’t designate a variable, and apparently I’ll have to rename $ description because Is this already a product description? And do I understand correctly that I need to designate it in catalog\controller\product\product.php ??
ps: additional created column descriptionm data type: TEXT in table oc_manufacturer

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zoozag, 2017-10-15
@Mixa_007

The main file responsible for displaying the product card page is the controller catalog\controller\product\product.php
The variables that are displayed in the template are stored inside the $data object.
Those. if the template displays $description, the controller must be set to $data['description']

<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>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question