ContextErrorException 注意:未定义索引:ps_sharebuttons.php 行 138 中的产品
ContextErrorException Notice: Undefined index: product in ps_sharebuttons.php line 138
当我启用 degub 模式时,我的 prestashop 1.7 项目出现了这个错误:
ContextErrorException 注意:未定义的索引:ps_sharebuttons.php 第 138 行中的产品。
第 138 行看起来像:
$key = 'ps_sharebuttons|' 。 $参数['product']['id_product'];
完整代码:
public function renderWidget($hookName, array $params)
{
$key = 'ps_sharebuttons|' . $params['product']['id_product'];
if (!empty($params['product']['id_product_attribute'])) {
$key .= '|' . $params['product']['id_product_attribute'];
}
if (!$this->isCached($this->templateFile, $this->getCacheId($key))) {
$this->smarty->assign($this->getWidgetVariables($hookName, $params));
}
请帮忙!
好吧,这似乎是 ps_sharebuttons 模块的问题,请检查最新版本,也许吧?
如果你只是想摆脱警告,只需修改代码如下:
public function renderWidget($hookName, array $params)
{
if (isset($params['product'])) {
$key = 'ps_sharebuttons|' . $params['product']['id_product'];
rest of the code here ...
}
当我启用 degub 模式时,我的 prestashop 1.7 项目出现了这个错误: ContextErrorException 注意:未定义的索引:ps_sharebuttons.php 第 138 行中的产品。
第 138 行看起来像:
$key = 'ps_sharebuttons|' 。 $参数['product']['id_product'];
完整代码:
public function renderWidget($hookName, array $params)
{
$key = 'ps_sharebuttons|' . $params['product']['id_product'];
if (!empty($params['product']['id_product_attribute'])) {
$key .= '|' . $params['product']['id_product_attribute'];
}
if (!$this->isCached($this->templateFile, $this->getCacheId($key))) {
$this->smarty->assign($this->getWidgetVariables($hookName, $params));
}
请帮忙!
好吧,这似乎是 ps_sharebuttons 模块的问题,请检查最新版本,也许吧?
如果你只是想摆脱警告,只需修改代码如下:
public function renderWidget($hookName, array $params)
{
if (isset($params['product'])) {
$key = 'ps_sharebuttons|' . $params['product']['id_product'];
rest of the code here ...
}