[英]How to resolve PrestaShop notice involving Array to string conversion issue?
[英]How to resolve the prestashop notice?
我正在嘗試解決這些持續顯示在日志中的通知:
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}
打開/themes/YOUR_THEME/product-list-colors.tpl
搜索
{foreach from=$colors_list item='color'}
並添加一個條件,該條件將檢查是否設置了'$ colors_list'變量。 最終的代碼如下所示:
{if isset($colors_list)}
//Current foreach loop code
{/if}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.