Good day dear visitors of our site, we all know that in opencart manufacturers are displayed on a separate page, but often the owners of online stores would display manufacturer goods directly to the card, well, what if you have to mean going to do, and so in this article we Screw photos of our products is in the product card with the ability to enable and disable from admin panel, as well as with the ability to change the size of the image maker, and so proceed.
1. First, let us create the desired field in the admin panel.
The changes will make in the following files:
1 2 3 |
βadmin/language/russian/setting/setting.phpβ β Here we add translation linguistic variables. βadmin/controller/setting/setting.phpβ β but here already we receive and process variables and language settings. βadmin/view/template/setting/setting.tplβ β derive from the settings in the form of store settings. |
1. File βadmin/language/russian/setting/setting.phpβ. In any place in the file ( between) is inserted:
1 2 |
$_['entry_manufacturer_image'] = 'The size of the manufacturer's logo on the item card:'; $_['entry_show_manufacturer_image'] = 'Show logo of the manufacturer:'; |
All language variables we added, we now need to move these variables in the template visibility well and accordingly create/receive and process settings.
2. File βadmin/controller/setting/setting.phpβ. The function index() (~30 line) after the code:
1 |
$this->data['heading_title'] = $this->language->get('heading_title'); |
We will add:
1 2 |
$this->data['entry_manufacturer_image'] = $this->language->get('entry_manufacturer_image'); $this->data['entry_show_manufacturer_image'] = $this->language->get('entry_show_manufacturer_image'); |
We all ended up with the linguistic variables. Next, after the code (~330 line):
1 2 3 4 5 |
if (isset($this->request->post['config_name'])) { $this->data['config_name'] = $this->request->post['config_name']; } else { $this->data['config_name'] = $this->config->get('config_name'); } |
We need to add:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# Image width if (isset($this->request->post['config_manufacturer_image_width'])) { $this->data['config_manufacturer_image_width'] = $this->request->post['config_manufacturer_image_width']; } else { $this->data['config_manufacturer_image_width'] = $this->config->get('config_manufacturer_image_width'); } # Image Height if (isset($this->request->post['config_manufacturer_image_height'])) { $this->data['config_manufacturer_image_height'] = $this->request->post['config_manufacturer_image_height']; } else { $this->data['config_manufacturer_image_height'] = $this->config->get('config_manufacturer_image_height'); } # Show/disable the image producer if (isset($this->request->post['config_show_manufacturer_image'])) { $this->data['config_show_manufacturer_image'] = $this->request->post['config_show_manufacturer_image']; } else { $this->data['config_show_manufacturer_image'] = $this->config->get('config_show_manufacturer_image'); } |
3. File βadmin/view/template/setting/setting.tplβ. All settings were received and processed, and we now have the template variables are available:
1 2 3 4 5 |
$entry_manufacturer_image; # The size of the manufacturer's logo on the item card: $entry_show_manufacturer_image; # Show image Manufacturer: $config_manufacturer_image_width; # (Setup) logotype width $config_manufacturer_image_height; # (Setup) logotype height $config_show_manufacturer_image; # (Set) show/hide logos |
All the settings we will be creating in the "Images" tab. We are looking for the code (~684 line):
1 2 3 4 5 6 7 8 9 10 |
<tr> <td><span class="required">*</span> <?php echo $entry_image_cart; ?></td> <td><input type="text" name="config_image_cart_width" value="<?php echo $config_image_cart_width; ?>" size="3" /> x <input type="text" name="config_image_cart_height" value="<?php echo $config_image_cart_height; ?>" size="3" /> <?php if ($error_image_cart) { ?> <span class="error"><?php echo $error_image_cart; ?></span> <?php } ?></td> </tr> </table> |
And before insert:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<tr> <td><?php echo $entry_manufacturer_image; ?></td> <td><input type="text" name="config_manufacturer_image_width" value="<?php echo $config_manufacturer_image_width; ?>" size="3" /> x <input type="text" name="config_manufacturer_image_height" value="<?php echo $config_manufacturer_image_height; ?>" size="3" /> </td> </tr> <tr> <td><?php echo $entry_show_manufacturer_image; ?></td> <td><?php if ($config_show_manufacturer_image) { ?> <input type="radio" name="config_show_manufacturer_image" value="1" checked="checked" /> <?php echo $text_yes; ?> <input type="radio" name="config_show_manufacturer_image" value="0" /> <?php echo $text_no; ?> <?php } else { ?> <input type="radio" name="config_show_manufacturer_image" value="1" /> <?php echo $text_yes; ?> <input type="radio" name="config_show_manufacturer_image" value="0" checked="checked" /> <?php echo $text_no; ?> <?php } ?></td> </tr> |
Now we need to go to settings and enter the values as settings they are empty by default. Example settings in the admin panel should look like this:
2. The second step, we will display our logo the manufacturer directly on the item card.
In some files, we will make changes:
1 2 3 |
1. βcatalog/model/catalog/product.phpβ β Here we change the product data database query to return the photos of our products. 2. βcatalog/controller/product/product.phpβ β Here, we will change the size of the photo and the manufacturer will add it to a variable, which will now be available in the template. 3. βcatalog/view/theme/template name/template/product/product.tplβ β add a photo, which was received from the controller to the template. |
1 |
$query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, (SELECT priceβ¦β¦β¦.. |
1 |
$query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, m.image AS mimage, (SELECT priceβ¦β¦β¦.. |
1 |
'sku' => $query->row['sku'], |
1 |
'mimage' => $query->row['mimage'], |
2. File βcatalog/controller/product/product.phpβ. The function index() we find the code (~199 line):
1 |
$this->load->model('tool/image'); |
1 2 |
$this->data['mimage'] = $this->model_tool_image->resize($product_info['mimage'], $this->config->get('config_manufacturer_image_width'), $this->config->get('config_manufacturer_image_height')); $this->data['config_show_manufacturer_image'] = $this->config->get('config_show_manufacturer_image'); |
3. File βcatalog/view/theme/template name/template/product/product.tplβ. We now have available a variable $mimage, it is the path to the photo products (120 Γ 50). Also still available is already variable $manufacturers, which is a link to the page producer in the store and the variable $config_show_manufacturer_image.
Now we move to the addition of the image links. After the code (~24 lines):
1 |
<div class="right"> |
1 2 3 4 5 |
<?php if ($config_show_manufacturer_image && (!empty($mimage))): ?> <a href="<?php echo $manufacturers; ?>"> <img style="float:right;margin-top:10px;" width="120" height="50" src="<?php echo $mimage; ?>" title="<?php echo $manufacturer; ?>" /> </a> <?php endif ?> |
Thank you for your attention, if you have questions to ask in the comments.
No Comment
You can post first response comment.