Opencart搜索和特殊页面图像错误


Opencart search and special pages image bug

产品搜索和特别优惠页面有错误。当我运行产品搜索并获得结果(或查看特别优惠页面)时。将鼠标放在产品图片上,得到:

"Notice: Undefined index: image_add in /home/database/public_html/catalog/view/theme/marcus/template/product/search.tpl on line 105Notice: Undefined index: image_add in /home/database/public_html/catalog/view/theme/marcus/template/product/search.tpl on line 115"... (also I add pic of problem)

未定义索引为的该部分的代码:

<?php
                    if($product['image_add'] != ''){
                        $file_headers = @get_headers($product['image_add']);
                        if($file_headers[0] == 'HTTP/1.1 404 Not Found') {
                            $exists = false;
                        }
                        else {
                            $exists = true;
                        }
                    }
                    if($product['image_add'] != '' && $exists){
?> 

Wierd 部分回合这个问题是其他页面中使用的代码部分相同,但仅在这两个页面(特别优惠和搜索结果页面)中存在该问题。

我的 OC 版本是 1.5.6.4和主题链接:

我不是真正的程序员,但对编码知之甚少(显然不足以解决这些问题)。因此,如果可能的话(并且如果您知道如何解决此问题),请尽可能简单地回答。

附言

我联系了主题创作者以获得支持,但直到今天我还没有从他那里得到答复。

问候

由于有问题的索引(显然)不存在,因此当您检查其值时,php 会抛出错误。 要避免此错误,您只需添加一些逻辑以确保它存在:

<?php
    if(isset($product['image_add']) && $product['image_add'] != ''){
        $file_headers = @get_headers($product['image_add']);
        if($file_headers[0] == 'HTTP/1.1 404 Not Found') {
            $exists = false;
        } else {
            $exists = true;
        }
    }
    if(isset($product['image_add']) && $product['image_add'] != '' && $exists){
?>