2014-02-11 58 views
1
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個錯誤總是出現在讓步中,所以它可能是一個插件/主題衝突。第一行是指以下插件:警告:爲Magento錯誤日誌中的foreach()提供的無效參數

http://bit.ly/1dfpIID

,其他三個都指向朝着我所相信的是價格滑塊附帶在產品頁面上的主題。

鏈接到開發站點:http://bit.ly/1mAxK2a

該網站是由themeforest運行Magento的1.8.1一個主題叫做地鐵店面。

這裏是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

有誰知道這些錯誤的意思或如何解決這些問題?

回答

2

這意味着你傳遞的東西不是數組。

您必須驗證之前:

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

[編輯] 在您的代碼 「的foreach($ filterableFeatures爲$功能)」 和 「的foreach($這個 - > filterableFeatures爲$功能)」 有沒有保護。

1

第16行,該方法返回一個字符串,它要麼是空字符串或字符串數​​據:

$filterableFeatures = $this->getLayer()->getFilterableFeatures(); 

我建議你嘗試先解決這個問題,看看爲什麼它不返回任何東西,但快速的解決方法是檢查,看看是否您嘗試運行的foreach之前的數組:

if (is_array($filterableFeatures)) { 
    foreach ($filterableFeatures as $feature) { 

當然,因爲這不是問題的根源,這可能會破壞其它的東西,所以一定要先找出問題的根源。我猜測'Price.php'由於'View.php'而錯誤。所以如果你修復'View.php',你最終可能會修復'Price.php'。

相關問題