dongmopu6734 2014-04-08 21:58
浏览 66
已采纳

致命错误:在/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php中的非对象上调用成员函数getId()

After migrating Magento to a new server I get this error on the dreaded white screen when trying to save a product:

Fatal error: Call to a member function getId() on a non-object in ...app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php on line 587

Here is the code on line 587

if (Mage::app()->isSingleStoreMode()) {
        $product->setWebsiteIds(array(Mage::app()->getStore(true)->getWebsite()->getId()));
    }

Method from same section this is lines 556-588:

/**
 * Initialize product before saving
 */
protected function _initProductSave()
{
    $product     = $this->_initProduct();
    $productData = $this->getRequest()->getPost('product');
    if ($productData) {
        $this->_filterStockData($productData['stock_data']);
    }

    /**
     * Websites
     */
    if (!isset($productData['website_ids'])) {
        $productData['website_ids'] = array();
    }

    $wasLockedMedia = false;
    if ($product->isLockedAttribute('media')) {
        $product->unlockAttribute('media');
        $wasLockedMedia = true;
    }

    $product->addData($productData);

    if ($wasLockedMedia) {
        $product->lockAttribute('media');
    }

    if (Mage::app()->isSingleStoreMode()) {
        $product->setWebsiteIds(array(Mage::app()->getStore(true)->getWebsite()->getId()));
    }
  • 写回答

1条回答 默认 最新

  • douli4337 2014-09-16 23:40
    关注

    I realize this is old, but I was having a similar problem on a 1.9.0.1 store. When I turned on the cache it worked! With the cache off and cleared it didn't. Not sure why.

    Hopefully this helps.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突