2016-04-26 8 views
0

の非オブジェクト上のgetId()メンバ関数への呼び出しテンプレートintensoでMagneto 1.9.2を使用しています...さらに、スライダ、製品のスクリーン、バナースライダ、プロダクトスライダなど、多くの種類のモジュールがあります。 bannersliderを持っていますが、私は変更を行う場合は、エラーで落ちるMagentoの:Magentoエラー

Fatal error: Call to a member function getId() on a non-object in /home/dev/web/app/code/local/Itactica/LogoSlider/Model/Resource/Slider/Logos.php on line 33

すべてのコードは次のとおりです。

public function saveLogosRelation($slider, $data){ 
    if (!is_array($data)) { 
     $data = array(); 
    } 
    $deleteCondition = $this->_getWriteAdapter()->quoteInto('slider_id=?', $slider->getId()); 
    $this->_getWriteAdapter()->delete($this->getMainTable(), $deleteCondition); 

    foreach ($data as $logoId => $info) { 
     $this->_getWriteAdapter()->insert($this->getMainTable(), array(
      'slider_id' => $slider->getId(), 
      'logo_id' => $logoId, 
      'position' => @$info['position'] 
     )); 
    } 
    return $this; 
} 

行33

$this->_getWriteAdapter()->insert($this->getMainTable(), array(
       'slider_id' => $slider->getId() 
です

このgetItメソッドを修復する方法はありますか? 私はすべてのことを試みますが、それはまだ動作していません。手伝って頂けますか ?ありがとうございます;)

答えて

0

あなたはprint_r($slider)またはvar_dump($slider)のいずれかの後に次の機能で行ってください。次に、idがスライダオブジェクトのデータメンバであるかどうかを調べます。

public function saveLogosRelation($slider, $data){ 
 

 
    echo "<pre>"; 
 
    print_r($slider); // here you will get display all data member of slider then you will get idea how to get id 
 
    
 
    exit; 
 
    
 
    if (!is_array($data)) { 
 
     $data = array(); 
 
    } 
 
    $deleteCondition = $this->_getWriteAdapter()->quoteInto('slider_id=?', $slider->getId()); 
 
    $this->_getWriteAdapter()->delete($this->getMainTable(), $deleteCondition); 
 

 
    foreach ($data as $logoId => $info) { 
 
     $this->_getWriteAdapter()->insert($this->getMainTable(), array(
 
      'slider_id' => $slider->getId(), 
 
      'logo_id' => $logoId, 
 
      'position' => @$info['position'] 
 
     )); 
 
    } 
 
    return $this; 
 
}

あなたが任意のクエリにまだ

おかげ

を持っているなら、私を知ってみましょう
関連する問題