大家有没有遇到过这种情况“Call to a member function getCustomerIdFieldName() on a non-object in ”

解决方案 »

  1.   

    这个是magento里面的代码。
    public function loadByCustomer($customer, $create = false)
        {
            if ($customer instanceof Mage_Customer_Model_Customer) {
                $customer = $customer->getId();
            }        $customerIdFieldName = $this->_getResource()->getCustomerIdFieldName();        $this->_getResource()->load($this, $customer, $customerIdFieldName);
            if (!$this->getId() && $create) {
                $this->setCustomerId($customer);
                $this->setSharingCode($this->_getSharingRandomCode());
                $this->save();
            }        return $this;
        }
      

  2.   

    由于对magento架构不熟悉,所以不知从何找这个错误的原因。
      

  3.   

    这问题可能是 没有引入需要的类库文件,include引入,仔细查看头部引入或者这个函数getCustomerIdFieldName()定义了没。
      

  4.   

    我没猜错的话这段代码是处理数据库查询结果的。可能是SQL语句出错了,输出数据库返回的错误信息
      

  5.   


    主要是用print_r($this->_getResource())打印不出类的详细信息。这个是获取那个类的信息的
      

  6.   

    在IDE开发工具里 ctrl+点击...