Подписывание картинок
1. Полный бекап
2. Изменить базу
в oc_product_image добавить поле image_desc (varchar(255) can be null)
3. Админка
admin/view/template/catalog/product_form.tpl
<tr> <td class="left"><input type="hidden" name="product_image[<?php echo $image_row; ?>]" value="<?php echo $product_image['file']; ?>" id="image<?php echo $image_row; ?>" /> <img src="<?php echo $product_image['preview']; ?>" alt="" id="preview<?php echo $image_row; ?>" class="image" onclick="image_upload('image<?php echo $image_row; ?>', 'preview<?php echo $image_row; ?>');" /></td> <td class="left"><a onclick="$('#image_row<?php echo $image_row; ?>').remove();" class="button"><span><?php echo $button_remove; ?></span></a></td> </tr>заменить на
<tr> <td class="left"><input type="hidden" name="product_image[<?php echo $image_row; ?>]" value="<?php echo $product_image['file']; ?>" id="image<?php echo $image_row; ?>" /> <img src="<?php echo $product_image['preview']; ?>" alt="" id="preview<?php echo $image_row; ?>" class="image" onclick="image_upload('image<?php echo $image_row; ?>', 'preview<?php echo $image_row; ?>');" /></td> <td><input type='text' name="image_desc[<?php echo $image_row; ?>]" value='<?php echo $product_image['image_desc']; ?>'></td> <td class="left"><a onclick="$('#image_row<?php echo $image_row; ?>').remove();" class="button"><span><?php echo $button_remove; ?></span></a></td> </tr> ,
function addImage() { html = '<tbody id="image_row' + image_row + '">'; html += '<tr>'; html += '<td class="left"><input type="hidden" name="product_image[' + image_row + ']" value="" id="image' + image_row + '" /><img src="<?php echo $no_image; ?>" alt="" id="preview' + image_row + '" class="image" onclick="image_upload('image' + image_row + '', 'preview' + image_row + '');" /></td>'; html += '<td class="left"><a onclick="$('#image_row' + image_row + '').remove();" class="button"><span><?php echo $button_remove; ?></span></a></td>'; html += '</tr>'; html += '</tbody>'; $('#images tfoot').before(html); image_row++;}заменить на
function addImage() { html = '<tbody id="image_row' + image_row + '">'; html += '<tr>'; html += '<td class="left"><input type="hidden" name="product_image[' + image_row + ']" value="" id="image' + image_row + '" /><img src="<?php echo $no_image; ?>" alt="" id="preview' + image_row + '" class="image" onclick="image_upload('image' + image_row + '', 'preview' + image_row + '');" /></td>'; [color=#FF0000]html += '<td><input type="text" name="image_desc[' + image_row + ']" value=''></td>';[/color] html += '<td class="left"><a onclick="$('#image_row' + image_row + '').remove();" class="button"><span><?php echo $button_remove; ?></span></a></td>'; html += '</tr>'; html += '</tbody>'; $('#images tfoot').before(html); image_row++;},admin/controller/catalog/product.php
if (isset($product_info)) { $results = $this->model_catalog_product->getProductImages($this->request->get['product_id']); foreach ($results as $result) { if ($result['image'] && file_exists(DIR_IMAGE . $result['image'])) { $this->data['product_images'][] = array( 'preview' => $this->model_tool_image->resize($result['image'], 100, 100), 'file' => $result['image'] ); } else { $this->data['product_images'][] = array( 'preview' => $this->model_tool_image->resize('no_image.jpg', 100, 100), 'file' => $result['image'] ); } } }заменить на
if (isset($product_info)) { $results = $this->model_catalog_product->getProductImages($this->request->get['product_id']); foreach ($results as $result) { if ($result['image'] && file_exists(DIR_IMAGE . $result['image'])) { $this->data['product_images'][] = array( 'preview' => $this->model_tool_image->resize($result['image'], 100, 100), 'file' => $result['image'], 'image_desc' => $result['image_desc'] ); } else { $this->data['product_images'][] = array( 'preview' => $this->model_tool_image->resize('no_image.jpg', 100, 100), 'file' => $result['image'], 'image_desc' => $result['image_desc'] ); } } } admin/model/catalog/product.php
в addProduct и в editProduct
if (isset($data['product_image'])) { foreach ($data['product_image'] as $image) { $this->db->query("INSERT INTO " . DB_PREFIX . "product_image SET product_id = '" . (int)$product_id . "', image = '" . $this->db->escape($image) . "'"); } }заменить на
$product_image_desc = array(); $i=0; if (isset($data['product_image'])) { foreach ($data['product_image'] as $image) { $product_image_desc[$i][0] = $image; $i++; } } $k = $i; $i=0; if (isset($data['image_desc'])) { foreach ($data['image_desc'] as $desc) { $product_image_desc[$i][1] = $desc; $i++; } } for ($i=$k-1;$i>=0;$i--) { $this->db->query("INSERT INTO " . DB_PREFIX . "product_image SET product_id = '" . (int)$product_id . "', image = '" . $this->db->escape($product_image_desc[$i][0]) . "', image_desc = '". $this->db->escape($product_image_desc[$i][1]) . "'"); },
public function getProductImages($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "'"); return $query->rows; }заменить на
public function getProductImages($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "' ORDER BY product_image_id desc"); return $query->rows; }
4. Для отображенияв catalog/model/catalog/product.php
public function getProductImages($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "'"); return $query->rows; }заменить на
public function getProductImages($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "' ORDER BY product_image_id desc"); return $query->rows; },в catalog/controller/product/product.php
$this->data['images'] = array(); $results = $this->model_catalog_product->getProductImages($this->request->get['product_id']); foreach ($results as $result) { $this->data['images'][] = array( 'popup' => $this->model_tool_image->resize($result['image'] , $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height')), 'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get('config_image_additional_width'), $this->config->get('config_image_additional_height')) ); }заменить на
$this->data['images'] = array(); $results = $this->model_catalog_product->getProductImages($this->request->get['product_id']); foreach ($results as $result) { $this->data['images'][] = array( 'popup' => $this->model_tool_image->resize($result['image'] , $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height')), 'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get('config_image_additional_width'), $this->config->get('config_image_additional_height')), 'image_desc' => $result['image_desc'] ); }в catalog/view/theme/ваша тема/template/product/product.tpl
<div id="tab_image" class="tab_page"> <?php if ($images) { ?> <div style="display: inline-block;"> <?php foreach ($images as $image) { ?> <div style="display: inline-block; float: left; text-align: center; margin-left: 5px; margin-right: 5px; margin-bottom: 10px;"><a href="<?php echo $image['popup']; ?>" title="<?php echo $heading_title; ?>" class="thickbox" rel="gallery"><img src="<?php echo $image['thumb']; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" style="border: 1px solid #DDDDDD; margin-bottom: 3px;" /></a> <span style="font-size: 11px;"><?php echo $text_enlarge; ?></span></div> <?php } ?> </div> <?php } else { ?> <div style="background: #F7F7F7; border: 1px solid #DDDDDD; padding: 10px; margin-bottom: 10px;"><?php echo $text_no_images; ?></div> <?php } ?> </div>заменить на
<div id="tab_image" class="tab_page"> <?php if ($images) { ?> <div style="display: inline-block;"> <?php foreach ($images as $image) { ?> <div style="display: inline-block; float: left; text-align: center; margin-left: 5px; margin-right: 5px; margin-bottom: 10px;"><a href="<?php echo $image['popup']; ?>" title="<?php echo $heading_title; ?>" class="thickbox" rel="gallery"><img src="<?php echo $image['thumb']; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" style="border: 1px solid #DDDDDD; margin-bottom: 3px;" /></a> <span style="font-size: 11px;"><?php echo $image['image_desc']; ?></span></div> <?php } ?> </div> <?php } else { ?> <div style="background: #F7F7F7; border: 1px solid #DDDDDD; padding: 10px; margin-bottom: 10px;"><?php echo $text_no_images; ?></div> <?php } ?> </div>