gpt4 book ai didi

php - 警告 : Invalid argument supplied for foreach() in Magento error log

转载 作者:行者123 更新时间:2023-12-03 07:46:43 26 4
gpt4 key购买 nike

2014-02-11T11:12:15+00:00 ERR (3): Warning: Invalid argument supplied for foreach()  in /var/www/magento/app/code/local/Bintime/Sinchimport/Block/Layer/View.php on line 19
2014-02-11T11:12:17+00:00 ERR (3): Notice: Undefined variable: bgHandle in /var/www/magento/app/code/community/Magehouse/Slider/Block/Catalog/Layer/Filter/Price.php on line 457
2014-02-11T11:12:17+00:00 ERR (3): Notice: Undefined variable: bgSlider in /var/www/magento/app/code/community/Magehouse/Slider/Block/Catalog/Layer/Filter/Price.php on line 461
2014-02-11T11:12:17+00:00 ERR (3): Notice: Undefined variable: bgRange in /var/www/magento/app/code/community/Magehouse/Slider/Block/Catalog/Layer/Filter/Price.php on line 465

我一直在清除旧的错误日志,这让我陷入了困境。我不知道是哪个文件导致了问题(如果有的话)。上面的 4 个错误总是在让步中弹出,所以它可能是插件/主题冲突。第一行是指以下插件:

http://bit.ly/1dfpIID

其他三个指向我认为是产品页面主题附带的价格 slider 。

链接到开发网站: http://bit.ly/1mAxK2a

该网站正在运行 Magento 1.8.1,主题为来自 themeforest 的名为 metro store。

这是 View.php:
<?php

class Bintime_Sinchimport_Block_Layer_View extends Mage_Catalog_Block_Layer_View
{

protected $filterableFeatures = array();

/**
* Prepare child blocks
*
* @return Mage_Catalog_Block_Layer_View
*/
protected function _prepareLayout()
{
//получение списка фич, по которым строися навигация
$filterableFeatures = $this->getLayer()->getFilterableFeatures();
$filterBlockName = 'sinchimport/layer_filter_feature'; //block
foreach ($filterableFeatures as $feature) {
$this->filterableFeatures[] = $feature;
$featureBlock = $this->getLayout()->createBlock($filterBlockName)
->setLayer($this->getLayer())
->setAttributeModel($feature)
->init();
$this->setChild('feature_' . $feature['feature_id'] . '_filter',
$featureBlock
);
}
/* ------------ */
return parent::_prepareLayout();
}

/**
* Get all layer filters
*
* @return array
*/
public function getFilters()
{
$filters = parent::getFilters();
/* ------------ */
foreach ($this->filterableFeatures as $feature) {
$filters[] = $this->getChild('feature_' . $feature['feature_id'] . '_filter');
}
/* ------------ */

return $filters;
}
}

这是 Price.php:

http://pastebin.com/BCyFxCe7

有谁知道这些错误是什么意思或如何解决它们?

最佳答案

这意味着您正在向 foreach 传递不是数组的东西。

您必须先验证:

if (count($array) > 0 && is_array($array)) {
foreach ($array as $key=>$value) {
//code here
}
}

[编辑]
在您的代码中“foreach ($filterableFeatures as $feature)”和“foreach ($this->filterableFeatures as $feature)”没有保护。

关于php - 警告 : Invalid argument supplied for foreach() in Magento error log,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21705942/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com