Перейти до вмісту
Пошук в
  • Детальніше...
Шукати результати, які ...
Шукати результати в ...

[Решено] Дополнительная вкладка с изображениями в карточке товара


michnoff

Recommended Posts

Хочу решить проблему с выводом дополнительной вкладки с изображениями в карточке товара! Версия 1.5.5.1.1 http://marioshop.by/ Нашел готовое решение Add extra Image tab.:

 

Внес изменения по инструкцие, в админке дополнительная вкладка в товаре появилась, а в карточке товара вот такие ошибки 
 

Undefined variable: tab_images2 in /home/mariosho/public_html/vqmod/vqcache/vq2-catalog_view_theme_polianna_template_product_product.tpl on line 359
Notice:  Undefined variable: images_data in /home/mariosho/public_html/vqmod/vqcache/vq2-catalog_view_theme_polianna_template_product_product.tpl on line 370
 

 

 

Изменял файлы по инструкцие в catalog :

 

Go to catalog\controller\product\product.php
 
Find the following:-
 
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'))
);
}
 
And add after it:- 
 
 $data['images2'] = array();
        
        $results = $this->model_catalog_product->getProductImages2($this->request->get['product_id']);
        
        foreach ($results as $result) {
            $this->data['images2'][] = 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'))
            );
        }
==========================================================================================================================
Go to catalog\model\catalog\product.php
 
Find the following :-
 
public function getProductImages($product_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "' ORDER BY sort_order ASC");
 
return $query->rows;
}
 
And after add it:- 
 
  public function getProductImages2($product_id) {
        $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_image2 WHERE product_id = '" . (int)$product_id . "'");
        
        return $query->rows;
    }
 
 
=============================================================================================================================================
 
 
Go to catalog/view/theme/*/template/product/product.tpl
 
Find :- 
 
 <a href="#tab-description"><?php echo $tab_description; ?></a>
 
And add after it:-
 
 <a href="#tab-images2"><?php echo $tab_images2; ?></a>
 
Find:->
 
 
<div id="tab-description" class="tab-content"><?php echo $description; ?></div>
 
And add after it->
 
  <div id="tab-images2" class="tab-content">
                        <?php if ($images_data) { ?>
                        <div class="image-additional">
                          <?php foreach ($images_data as $image) { ?>
                          <a href="<?php echo $image['popup']; ?>" title="<?php echo $heading_title; ?>" class="colorbox"><img src="<?php echo $image['thumb']; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" /></a>
                          <?php } ?>
                        </div>
                        <?php } ?>
                    </div>
 
 
 
 
 
и Admin: 
 

 
Step 1: Run the following Query to database.
 
CREATE TABLE IF NOT EXISTS `".DB_PREFIX."product_image2` (
              `product_image_id` int(11) NOT NULL AUTO_INCREMENT,
              `product_id` int(11) NOT NULL,
              `image` varchar(255) DEFAULT NULL,
              `sort_order` int(3) NOT NULL DEFAULT '0',
              PRIMARY KEY (`product_image_id`)
            ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
 
 
========================================================================================================================================
Step 2:- Go to admin/controller/catalog/product.php and search the following:-
 
foreach ($product_images as $product_image) {
if ($product_image['image'] && file_exists(DIR_IMAGE . $product_image['image'])) {
$image = $product_image['image'];
} else {
$image = 'no_image.jpg';
}
 
$this->data['product_images'][] = array(
'image'      => $image,
'thumb'      => $this->model_tool_image->resize($image, 100, 100),
'sort_order' => $product_image['sort_order']
);
}
 
 
And after it add:
 
//Extra Images
        if (isset($this->request->post['product_image2'])) {
            $product_images2 = $this->request->post['product_image2'];
        } elseif (isset($this->request->get['product_id'])) {
            $product_images2 = $this->model_catalog_product->getProductImages2($this->request->get['product_id']);
        } else {
            $product_images2 = array();
        }
 
        $data['product_images2'] = array();
 
        foreach ($product_images2 as $product_image) {
            if ($product_image['image'] && file_exists(DIR_IMAGE . $product_image['image'])) {
                $image = $product_image['image'];
            } else {
                $image = 'no_image.jpg';
            }
            
            $this->data['product_images2'][] = array(
                'image'      => $image,
                'thumb'      => $this->model_tool_image->resize($image, 100, 100),
                'sort_order' => $product_image['sort_order']
            );
        }
 
============================================================================================================================================================
Step3 :- admin/model/catalog/product.php
 
Search the following:- 
 
if (isset($data['product_image'])) {
foreach ($data['product_image'] as $product_image) {
$this->db->query("INSERT INTO " . DB_PREFIX . "product_image SET product_id = '" . (int)$product_id . "', image = '" . $this->db->escape(html_entity_decode($product_image['image'], ENT_QUOTES, 'UTF-8')) . "', sort_order = '" . (int)$product_image['sort_order'] . "'");
}
}
 
And after it add:
 
 
//Extra Image
if (isset($data['product_image2'])) {
foreach ($data['product_image2'] as $product_image2) {
$this->db->query("INSERT INTO " . DB_PREFIX . "product_image2 SET product_id = '" . (int)$product_id . "', image = '" . $this->db->escape(html_entity_decode($product_image2['image'], ENT_QUOTES, 'UTF-8')) . "', sort_order = '" . (int)$product_image2['sort_order'] . "'");
}
}
============================================================================================================================================================
Step4 :- admin/model/catalog/product.php
Find the  following:- 
 
$this->db->query("DELETE FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "'");
 
if (isset($data['product_image'])) {
foreach ($data['product_image'] as $product_image) {
$this->db->query("INSERT INTO " . DB_PREFIX . "product_image SET product_id = '" . (int)$product_id . "', image = '" . $this->db->escape(html_entity_decode($product_image['image'], ENT_QUOTES, 'UTF-8')) . "', sort_order = '" . (int)$product_image['sort_order'] . "'");
}
}
 
And after it add: 
 
//Extra Images
 
$this->db->query("DELETE FROM " . DB_PREFIX . "product_image2 WHERE product_id = '" . (int)$product_id . "'");
        if (isset($data['product_image2'])) {
foreach ($data['product_image2'] as $product_image2) {
$this->db->query("INSERT INTO " . DB_PREFIX . "product_image2 SET product_id = '" . (int)$product_id . "', image = '" . $this->db->escape(html_entity_decode($product_image2['image'], ENT_QUOTES, 'UTF-8')) . "', sort_order = '" . (int)$product_image2['sort_order'] . "'");
}
}
 
 
============================================================================================================================================================Step5 :- admin/model/catalog/product.php
 
Search the following:- 
 
$data = array_merge($data, array('product_image' => $this->getProductImages($product_id)));
 
And after it add :- 
 
$data = array_merge($data, array('product_image2' => $this->getProductImages2($product_id)));
============================================================================================================================================================
Step6 :- admin/model/catalog/product.php
 
Search the following:- 
 
public function deleteProduct($product_id) {
 
And after add it:- 
 
$this->db->query("DELETE FROM " . DB_PREFIX . "product_image2 WHERE product_id = '" . (int)$product_id . "'");
 
Search the following:-
 
public function getProductImages($product_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "'");
 
return $query->rows;
}
 
And After add it:-
 
public function getProductImages2($product_id) {
        $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_image2 WHERE product_id = '" . (int)$product_id . "'");
        
        return $query->rows;
    }
 
 
============================================================================================================================================================
Step7 : Go to admin/view/template/catalog/product_form.tpl:-
 
Find the following
 
<a href="#tab-image"><?php echo $tab_image; ?></a>
 
And add after it:- 
 
<a href="#tab-image2"><?php echo "Slider Images"; ?>
 
============================================================================================================================================================
 
Step8 : Go to admin/view/template/catalog/product_form.tpl:-
 
Find the following:- 
<div id="tab-image">
          <table id="images" class="list">
            <thead>
              <tr>
                <td class="left"><?php echo $entry_image; ?></td>
                <td class="right"><?php echo $entry_sort_order; ?></td>
                <td></td>
              </tr>
            </thead>
            <?php $image_row = 0; ?>
            <?php foreach ($product_images as $product_image) { ?>
            <tbody id="image-row<?php echo $image_row; ?>">
              <tr>
                <td class="left"><div class="image"><img src="<?php echo $product_image['thumb']; ?>" alt="" id="thumb<?php echo $image_row; ?>" />
                    <input type="hidden" name="product_image[<?php echo $image_row; ?>][image]" value="<?php echo $product_image['image']; ?>" id="image<?php echo $image_row; ?>" />
                    <br />
                    <a onclick="image_upload('image<?php echo $image_row; ?>', 'thumb<?php echo $image_row; ?>');"><?php echo $text_browse; ?></a>  |  <a onclick="$('#thumb<?php echo $image_row; ?>').attr('src', '<?php echo $no_image; ?>'); $('#image<?php echo $image_row; ?>').attr('value', '');"><?php echo $text_clear; ?></a></div></td>
                <td class="right"><input type="text" name="product_image[<?php echo $image_row; ?>][sort_order]" value="<?php echo $product_image['sort_order']; ?>" size="2" /></td>
                <td class="left"><a onclick="$('#image-row<?php echo $image_row; ?>').remove();" class="button"><?php echo $button_remove; ?></a></td>
              </tr>
            </tbody>
            <?php $image_row++; ?>
            <?php } ?>
            <tfoot>
              <tr>
                <td colspan="2"></td>
                <td class="left"><a onclick="addImage();" class="button"><?php echo $button_add_image; ?></a></td>
              </tr>
            </tfoot>
          </table>
        </div>
 
 
 
And after it add :-
 
 
<div id="tab-image2">
          <table id="images2" class="list">
            <thead>
              <tr>
                <td class="left"><?php echo $entry_image; ?></td>
                <td class="right"><?php echo $entry_sort_order; ?></td>
                <td></td>
              </tr>
            </thead>
            <?php $image2_row = 0; ?>
            <?php if ( isset($product_images2) ) {?>
            <?php   foreach ($product_images2 as $product_image2) { ?>
            <tbody id="image2-row<?php echo $image2_row; ?>">
              <tr>
                <td class="left"><div class="image"><img src="<?php echo $product_image2['thumb']; ?>" alt="" id="thumb_<?php echo $image2_row; ?>" />
                    <input type="hidden" name="product_image2[<?php echo $image2_row; ?>][image]" value="<?php echo $product_image2['image']; ?>" id="image2_<?php echo $image2_row; ?>" />
                    <br />
                    <a onclick="image_upload('image2_<?php echo $image2_row; ?>', 'thumb_<?php echo $image2_row; ?>');"><?php echo $text_browse; ?></a>  |  <a onclick="$('#thumb_<?php echo $image2_row; ?>').attr('src', '<?php echo $no_image; ?>'); $('#image2<?php echo $image2_row; ?>').attr('value', '');"><?php echo $text_clear; ?></a></div></td>
                <td class="right"><input type="text" name="product_image2[<?php echo $image2_row; ?>][sort_order]" value="<?php echo $product_image2['sort_order']; ?>" size="2" /></td>
                <td class="left"><a onclick="$('#image2-row<?php echo $image2_row; ?>').remove();" class="button"><?php echo $button_remove; ?></a></td>
              </tr>
            </tbody>
            <?php       $image2_row++; ?>
            <?php   } ?>
            <?php } ?>
            <tfoot>
              <tr>
                <td colspan="2"></td>
                <td class="left"><a onclick="addImage2();" class="button"><?php echo $button_add_image; ?></a></td>
              </tr>
            </tfoot>
          </table>
        </div>
 
 
============================================================================================================================================================
Step9 : Go to admin/view/template/catalog/product_form.tpl:-
 
Find the following:-
 
<script type="text/javascript"><!--
var image_row = <?php echo $image_row; ?>;
 
function addImage() {
    html  = '<tbody id="image-row' + image_row + '">';
html += '  <tr>';
html += '    <td class="left"><div class="image"><img src="<?php echo $no_image; ?>" alt="" id="thumb' + image_row + '" /><input type="hidden" name="product_image[' + image_row + '][image]" value="" id="image' + image_row + '" /><br /><a onclick="image_upload(\'image' + image_row + '\', \'thumb' + image_row + '\');"><?php echo $text_browse; ?></a>  |  <a onclick="$(\'#thumb' + image_row + '\').attr(\'src\', \'<?php echo $no_image; ?>\'); $(\'#image' + image_row + '\').attr(\'value\', \'\');"><?php echo $text_clear; ?></a></div></td>';
html += '    <td class="right"><input type="text" name="product_image[' + image_row + '][sort_order]" value="" size="2" /></td>';
html += '    <td class="left"><a onclick="$(\'#image-row' + image_row  + '\').remove();" class="button"><?php echo $button_remove; ?></a></td>';
html += '  </tr>';
html += '</tbody>';
 
$('#images tfoot').before(html);
 
image_row++;
}
 
And after add it: ->
 
var image2_row = <?php echo $image2_row; ?>;
 
function addImage2() {
    html  = '<tbody id="image2-row' + image2_row + '">';
    html += '  <tr>';
    html += '    <td class="left"><div class="image"><img src="<?php echo $no_image; ?>" alt="" id="thumb_' + image2_row + '" /><input type="hidden" name="product_image2[' + image2_row + '][image]" value="" id="image2_' + image2_row + '" /><br /><a onclick="image_upload(\'image2_' + image2_row + '\', \'thumb_' + image2_row + '\');"><?php echo $text_browse; ?></a>  |  <a onclick="$(\'#thumb_' + image2_row + '\').attr(\'src\', \'<?php echo $no_image; ?>\'); $(\'#image2' + image2_row + '\').attr(\'value\', \'\');"><?php echo $text_clear; ?></a></div></td>';
    html += '    <td class="right"><input type="text" name="product_image2[' + image2_row + '][sort_order]" value="" size="2" /></td>';
    html += '    <td class="left"><a onclick="$(\'#image2-row' + image2_row  + '\').remove();" class="button"><?php echo $button_remove; ?></a></td>';
    html += '  </tr>';
    html += '</tbody>';
    
    $('#images2 tfoot').before(html);
    
    image2_row++;
}
 
 
+======================================================================================================================================
 
 
 
Внес все эти изменения. в админке дополнительная вкладка в товаре появилась, а в карточке товара вот такие ошибки 
 

Undefined variable: tab_images2 in /home/mariosho/public_html/vqmod/vqcache/vq2-catalog_view_theme_polianna_template_product_product.tpl on line 359
Notice:  Undefined variable: images_data in /home/mariosho/public_html/vqmod/vqcache/vq2-catalog_view_theme_polianna_template_product_product.tpl on line 370
 
 
 
 

 

Admin section.txt

Front Section.txt

Змінено користувачем michnoff
Надіслати
Поділитися на інших сайтах


Undefined variable: tab_images2 -   не добавили языковую переменную 

Надіслати
Поділитися на інших сайтах

Undefined variable: tab_images2 -   не добавили языковую переменную 

А в какой файл ее добавить нужно? или это в таблицу бд нужно добавлять? В языковой файл в /catalog/language/russian/product?

Змінено користувачем michnoff
Надіслати
Поділитися на інших сайтах


Undefined variable: tab_images2 -   не добавили языковую переменную 

Спасибо! Разобрался с первой ошибкой- добавил переменную, вкладка появилась, но вторая ошибка осталась!

Надіслати
Поділитися на інших сайтах


не может получить  images_data ​прорвете на правильность контроллере и вывод картинок $image_data // может быть не созданный массив для наполнения $image_data = array(); 

Надіслати
Поділитися на інших сайтах

Гість
Ця тема закрита для публікації повідомлень.
  • Зараз на сторінці   0 користувачів

    • Ні користувачів, які переглядиють цю сторінку
×
×
  • Створити...

Important Information

На нашому сайті використовуються файли cookie і відбувається обробка деяких персональних даних користувачів, щоб поліпшити користувальницький інтерфейс. Щоб дізнатися для чого і які персональні дані ми обробляємо перейдіть за посиланням . Якщо Ви натиснете «Я даю згоду», це означає, що Ви розумієте і приймаєте всі умови, зазначені в цьому Повідомленні про конфіденційність.