[Решено] Ошибка вывода изображений в шаблоне Harvest Medicine

Тема в разделе "OpenCart", создана пользователем Moraxus, 26 май 2016.

Статус темы:
Закрыта.
  1. Moraxus

    Moraxus

    Регистрация:
    19 май 2016
    Сообщения:
    14
    Симпатии:
    0
    Ребят нужна оромная помощь по шаблону ! Установил настроил - все по мануалу шаблона - сейчас бьет ошибка !
    Код:
    Notice: Undefined variable: swapImg in /home/uleymkua/public_html/skelamlnew/catalog/controller/module/megnortabs.php on line 155
    Notice: Undefined variable: swapImg in /home/uleymkua/public_html/skelamlnew/catalog/controller/module/megnortabs.php on line 155
    Notice: Undefined variable: swapImg in/home/uleymkua/public_html/skelamlnew/catalog/controller/module/megnortabs.php on line 155
    Notice: Undefined variable: swapImg in/home/uleymkua/public_html/skelamlnew/catalog/controller/module/megnortabs.php on line 155
    Notice: Undefined variable: swapImg in/home/uleymkua/public_html/skelamlnew/catalog/controller/module/megnortabs.php on line 155
    
    Так же по не известной мне причине нет нескольких блоков ! - прошу помощи!
     
    Lasted edited by : 26 май 2016
  2. Dotrox

    Dotrox Команда форума

    Регистрация:
    27 ноя 2012
    Сообщения:
    3.198
    Симпатии:
    1.306
    Выложите сюда файл
    /catalog/controller/module/megnortabs.php
     
  3. Moraxus

    Moraxus

    Регистрация:
    19 май 2016
    Сообщения:
    14
    Симпатии:
    0
  4. Dotrox

    Dotrox Команда форума

    Регистрация:
    27 ноя 2012
    Сообщения:
    3.198
    Симпатии:
    1.306
    Вставляйте код в пост, а не выкладывайте на файлообменник.

    PHP:
    <?php
    class ControllerModulemegnortabs extends Controller {
        public function 
    index($setting) {
            
    $this->load->language('module/megnortabs');
           
            
    $data['heading_title'] = $this->language->get('heading_title');

            
    $data['text_tax'] = $this->language->get('text_tax');

            
    $data['button_cart'] = $this->language->get('button_cart');
            
    $data['button_wishlist'] = $this->language->get('button_wishlist');
            
    $data['button_compare'] = $this->language->get('button_compare');
           
            
    $data['tab_latest'] = $this->language->get('tab_latest');
              
    $data['tab_featured'] = $this->language->get('tab_featured');
              
    $data['tab_bestseller'] = $this->language->get('tab_bestseller');
              
    $data['tab_special'] = $this->language->get('tab_special');

            
    $this->load->model('catalog/product');
            
    $this->load->model('tool/image');

            
    // special product
           
            
    $data['specialproducts'] = array();

            
    $filter_data = array(
                
    'sort'  => 'pd.name',
                
    'order' => 'ASC',
                
    'start' => 0,
                
    'limit' => $setting['limit']
            );

            
    $results $this->model_catalog_product->getProductSpecials($filter_data);

            if (
    $results) {
                foreach (
    $results as $result) {
                    if (
    $result['image']) {
                        
    $image $this->model_tool_image->resize($result['image'], $setting['width'], $setting['height']);
                    } else {
                        
    $image $this->model_tool_image->resize('placeholder.png'$setting['width'], $setting['height']);
                    }
                   
                    
    //added for image swap
                   
                    
    $images $this->model_catalog_product->getProductImages($result['product_id']);

                    if(isset(
    $images[0]['image']) && !empty($images)){
                     
    $images $images[0]['image'];
                       }else
                       {
                       
    $images $image;
                       }
                       
                    
    //

                    
    if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
                        
    $price $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
                    } else {
                        
    $price false;
                    }

                    if ((float)
    $result['special']) {
                        
    $special $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')));
                    } else {
                        
    $special false;
                    }

                    if (
    $this->config->get('config_tax')) {
                        
    $tax $this->currency->format((float)$result['special'] ? $result['special'] : $result['price']);
                    } else {
                        
    $tax false;
                    }

                    if (
    $this->config->get('config_review_status')) {
                        
    $rating $result['rating'];
                    } else {
                        
    $rating false;
                    }

                    
    $data['specialproducts'][] = array(
                        
    'product_id'  => $result['product_id'],
                        
    'thumb'       => $image,
                        
    'thumb_swap'  => $this->model_tool_image->resize($images$this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')),
                        
    'name'        => $result['name'],
                        
    'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES'UTF-8')), 0$this->config->get('config_product_description_length')) . '..',
                        
    'price'       => $price,
                        
    'special'     => $special,
                        
    'tax'         => $tax,
                        
    'rating'      => $rating,
                        
    'href'        => $this->url->link('product/product''product_id=' $result['product_id'])
                    );
                }
               
            }
           
            
    //latest product
           
            
    $data['latestproducts'] = array();

            
    $filter_data = array(
                
    'sort'  => 'p.date_added',
                
    'order' => 'DESC',
                
    'start' => 0,
                
    'limit' => $setting['limit']
            );

            
    $results $this->model_catalog_product->getLatestproducts($setting['limit']);

            if (
    $results) {
                foreach (
    $results as $result) {
                    if (
    $result['image']) {
                        
    $image $this->model_tool_image->resize($result['image'], $setting['width'], $setting['height']);
                    } else {
                        
    $image $this->model_tool_image->resize('placeholder.png'$setting['width'], $setting['height']);
                    }
                   
                    
    //added for image swap
                   
                    
    $images $this->model_catalog_product->getProductImages($result['product_id']);

                    if(isset(
    $images[0]['image']) && !empty($images[0]['image'])){
                          
    $swapImg $images[0]['image'];
                       }

                    
    //


                    
    if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
                        
    $price $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
                    } else {
                        
    $price false;
                    }

                    if ((float)
    $result['special']) {
                        
    $special $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')));
                    } else {
                        
    $special false;
                    }

                    if (
    $this->config->get('config_tax')) {
                        
    $tax $this->currency->format((float)$result['special'] ? $result['special'] : $result['price']);
                    } else {
                        
    $tax false;
                    }

                    if (
    $this->config->get('config_review_status')) {
                        
    $rating $result['rating'];
                    } else {
                        
    $rating false;
                    }

                    
    $data['latestproducts'][] = array(
                        
    'product_id'  => $result['product_id'],
                        
    'thumb'       => $image,
                        
    'thumb_swap'  => $this->model_tool_image->resize($swapImg$this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')),
                        
    'name'        => $result['name'],
                        
    'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES'UTF-8')), 0$this->config->get('config_product_description_length')) . '..',
                        
    'price'       => $price,
                        
    'special'     => $special,
                        
    'tax'         => $tax,
                        
    'rating'      => $rating,
                        
    'href'        => $this->url->link('product/product''product_id=' $result['product_id']),
                    );
                }
            }
           
            
    // bestsellets
           
            
    $data['bestsellersproducts'] = array();

            
    $results $this->model_catalog_product->getBestSellerProducts($setting['limit']);

            if (
    $results) {
                foreach (
    $results as $result) {
                    if (
    $result['image']) {
                        
    $image $this->model_tool_image->resize($result['image'], $setting['width'], $setting['height']);
                    } else {
                        
    $image $this->model_tool_image->resize('placeholder.png'$setting['width'], $setting['height']);
                    }
                   
                    
    //added for image swap
                   
                    
    $images $this->model_catalog_product->getProductImages($result['product_id']);

                    if(isset(
    $images[0]['image']) && !empty($images[0]['image'])){
                          
    $swapImg $images[0]['image'];
                       }

                    
    //


                    
    if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
                        
    $price $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
                    } else {
                        
    $price false;
                    }

                    if ((float)
    $result['special']) {
                        
    $special $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')));
                    } else {
                        
    $special false;
                    }

                    if (
    $this->config->get('config_tax')) {
                        
    $tax $this->currency->format((float)$result['special'] ? $result['special'] : $result['price']);
                    } else {
                        
    $tax false;
                    }

                    if (
    $this->config->get('config_review_status')) {
                        
    $rating $result['rating'];
                    } else {
                        
    $rating false;
                    }

                    
    $data['bestsellersproducts'][] = array(
                        
    'product_id'  => $result['product_id'],
                        
    'thumb'       => $image,
                        
    'thumb_swap'  => $this->model_tool_image->resize($swapImg$this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')),
                        
    'name'        => $result['name'],
                        
    'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES'UTF-8')), 0$this->config->get('config_product_description_length')) . '..',
                        
    'price'       => $price,
                        
    'special'     => $special,
                        
    'tax'         => $tax,
                        
    'rating'      => $rating,
                        
    'href'        => $this->url->link('product/product''product_id=' $result['product_id']),
                    );
                }
            }

       
       
                if (
    file_exists(DIR_TEMPLATE $this->config->get('config_template') . '/template/module/megnortabs.tpl')) {
                    return 
    $this->load->view($this->config->get('config_template') . '/template/module/megnortabs.tpl'$data);
                }
        }
    }
    У вас тут есть два места с таким кодом:
    PHP:
     if(isset($images[0]['image']) && !empty($images[0]['image'])){
                          
    $swapImg $images[0]['image'];
                       } 
    Приведите его к такому виду:
    PHP:
     if(isset($images[0]['image']) && !empty($images[0]['image'])){
                          
    $swapImg $images[0]['image'];
                       } else {
        
    $swapImg 'no_image.png';
     
  5. Moraxus

    Moraxus

    Регистрация:
    19 май 2016
    Сообщения:
    14
    Симпатии:
    0
    спасибо помогло=)
     
Статус темы:
Закрыта.