Jump to content

Recommended Posts

День добрый. Дублирую вкладку "Рекомендуемуе" (создал копию таблицы product_related, внёс изменения в controller, module, thema - в admin и catalog), В админке всё нормально (появилось доп. поле "сопутствующие", записывается в БД), а на сайте во складке "сопутствующие товары" у продукта, нет изображения и выскакивает такая ошибка

 

Warning: imagecreatetruecolor(): Invalid image dimensions in /var/www/tehna/data/www/tehna.ru/system/library/image.php on line 74Warning: imagecolorallocate() expects parameter 1 to be resource, boolean given in /var/www/tehna/data/www/tehna.ru/system/library/image.php on line 82Warning: imagefilledrectangle() expects parameter 1 to be resource, boolean given in /var/www/tehna/data/www/tehna.ru/system/library/image.php on line 85Warning: imagecopyresampled() expects parameter 1 to be resource, boolean given in /var/www/tehna/data/www/tehna.ru/system/library/image.php on line 87Warning: imagejpeg() expects parameter 1 to be resource, boolean given in /var/www/tehna/data/www/tehna.ru/system/library/image.php on line 44Warning: imagedestroy() expects parameter 1 to be resource, boolean given in /var/www/tehna/data/www/tehna.ru/system/library/image.php on line 51
 

Где-то по пути теряются изображения, где не могу понять, не подскажите как определить?

Share this post


Link to post
Share on other sites

Изменены следующие файлы:
../catalog/controller/product/product.php (аналог $this->data['products'])

$this->data['products2'] = array();      
 $results = $this->model_catalog_product->getProductRelated2($this->request->get['product_id']);
            foreach ($results as $result) {
                if ($result['image']) {
                    $image = $this->model_tool_image->resize($result['image'], $this->config->get('config_image_related_width2'), $this->config->get('config_image_related_height2'));
                } else {
                    $image = false;
                }
 
                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_review_status')) {
                    $rating = (int)$result['rating'];
                } else {
                    $rating = false;
                }
       
                $this->data['products2'][] = array(
                    'product_id' => $result['product_id'],
                    'thumb'        => $image,
                    'name'  => $result['name'],
                    'price'        => $price,
                    'special'  => $special,
                    'rating'        => $rating,
                    'reviews'    => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
                    'href'  => $this->url->link('product/product', 'product_id=' . $result['product_id']),
                );
            }

 


../catalog/model/catalog/product.php (аналог public function getProductRelated($product_id))

 

public function getProductRelated2($product_id) {
        $product_data = array();
 
        $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_related2 pr LEFT JOIN " . DB_PREFIX . "product p ON (pr.related_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pr.product_id = '" . (int)$product_id . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");
 
        foreach ($query->rows as $result) {
            $product_data[$result['related_id']] = $this->getProduct($result['related_id']);
        }
       
        return $product_data;
    }


 

../тема/product/product.php (аналог php if ($products))


<?php if ($products2) { ?>
    <a href="#tab-related2"><?php echo $tab_related2; ?> (<?php echo count($products2); ?>)</a>
    <?php } ?>


Изменял так же в админке файлы, их не привожу так как в БД информация записывается.

Share this post


Link to post
Share on other sites

Нашёл ошибку в файле ../catalog/controller/product/product.php вместо переменной config_image_related_width2 и config_image_related_height2 нужно соответственно config_image_related_width и config_image_related_height

Share this post


Link to post
Share on other sites

не могли бы Вы поделиться что где меняли? тоже нужна реализация подобного.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.