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.

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

报告相同问题?

悬赏问题

  • ¥50 adb连接不到手机是怎么回事?
  • ¥15 vs2022无法联网
  • ¥15 TCP的客户端和服务器的互联
  • ¥15 VB.NET操作免驱摄像头
  • ¥15 笔记本上移动热点开关状态查询
  • ¥85 类鸟群Boids——仿真鸟群避障的相关问题
  • ¥15 CFEDEM自带算例错误,如何解决?
  • ¥15 有没有会使用flac3d软件的家人
  • ¥20 360摄像头无法解绑使用,请教解绑当前账号绑定问题,
  • ¥15 docker实践项目