Magento错误调用非对象中的成员函数getId()

时间:2016-04-26 04:05:47

标签: templates slider magento-1.9

我使用Magneto 1.9.2模板强化...... Intenso有很多种模块 - 滑块,产品屏幕,bannerlider,productslider ..我有一个bannerlider,但是如果我做出改变,magento会出现错误:

  

致命错误:在第33行的/home/dev/web/app/code/local/Itactica/LogoSlider/Model/Resource/Slider/Logos.php中的非对象上调用成员函数getId()< / p>

所有代码均为:

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方法的方法吗? 我尝试了所有的东西,但它还没有工作。你能帮助我吗 ?感谢..)

1 个答案:

答案 0 :(得分: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;
}

如果您还有任何查询,请告诉我

由于