2017-10-16 49 views
3

我的問題:這是我的第一個Open Cart項目,我不知道這個MVCL好)所以我需要爲OpenCart 2.3.0.2編寫ocmod修改,以便在產品頁面中添加製造商描述。年初,我發現ocmod爲附加製造商說明製造商網頁和編輯這個模塊對於我這個代碼:如何在product.tpl中爲製造商描述寫入true 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> 
      &nbsp;<br/>&nbsp; 
      <?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> 
      &nbsp;<br/>&nbsp; 
      <?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

解決此問題!我錯誤的使用地方添加代碼在控制器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> 
相關問題