如何解决prestashop通知?

时间:2016-09-09 09:42:06

标签: php html css prestashop prestashop-1.6

我正在尝试解决这些不断显示在我的日志中的注意事项:

PHP Notice:  Trying to get property of non-object in /srv/myShop/shop/cache/smarty/compile/4c/b2/41/4cb2418065875a76c823a0076b8a95132c849e33.file.product-list-colors.tpl.cache.php on line 32
PHP Notice:  Undefined index: colors_list in /srv/myShop/shop/cache/smarty/compile/4c/b2/41/4cb2418065875a76c823a0076b8a95132c849e33.file.product-list-colors.tpl.cache.php on line 32

以下是product-list-colors.tpl.cache.php的一个片段,包括第32行(第3行):

<ul class="color_to_pick_list clearfix">
    <?php  $_smarty_tpl->tpl_vars['color'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['color']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['colors_list']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['color']->key => $_smarty_tpl->tpl_vars['color']->value) {
$_smarty_tpl->tpl_vars['color']->_loop = true;

在这里你有主题/ simple-great / product-list-colors.tpl:

<ul class="color_to_pick_list clearfix">
{foreach from=$colors_list item='color'}
    <li>
        <a
        href="{$link->getProductLink($color.id_product, null, null, null, null, null, $color.id_product_attribute)|escape:'html':'UTF-8'}"
        id="color_{$color.id_product_attribute|intval}"
        class="color_pick"
        style="background: {$color.color};">
        </a>
    </li>
{/foreach}

1 个答案:

答案 0 :(得分:2)

打开/themes/YOUR_THEME/product-list-colors.tpl

搜索

{foreach from=$colors_list item='color'}

并添加一个条件,检查&#39; $ colors_list&#39;变量是否设置。最终的代码如下:

{if isset($colors_list)}
    //Current foreach loop code
{/if}