user2301064
user2301064

Reputation: 1

Magento can't save new products anymore

Everything was fine 'til this morning. I've tried clearing cache, re indexing, all tips I could find on the internet. Here is the message I'm getting Fatal error: Call to a member function getId() on a non-object in /home5/rockbott/public_html/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php on line 578

here is line 577 and 578:

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

A newly created product gives me Fatal Error message. Duplicated product gives me the same, but when I go to manage products it appears, but without SKU# and 0 stock count. When I try to edit that product again - I get Fatal Error. Please help me with my problem.

Thanks in advance.


Thanks for your response. Someone suggested that I clear log file and I did. I'm sorry I don't have the log file. Compiler is disabled as well. Would you be kind enough to take a look here: http://www.magentocommerce.com/boards/viewthread/347764/ I've posted more information there including reports. Thank you Anna

Upvotes: 0

Views: 1791

Answers (4)

pspahn
pspahn

Reputation: 2790

What appears to be causing it in my case is a remnant logging line in Mage.php that I was using to track events.

On line 447 I had:

Mage::log($name, null, 'events.log');

Removing this logging line resolved the issue.

Upvotes: 1

I had the same error. Solution turned out to be very simple: you need to replace getStore(true) to getStore(1). Its very strange because in PHP true same as 1 ... but in this it was a mistake. If you make a "more correct" and write:

$product->setWebsiteIds(array(Mage::app()->getStore(Mage::app()->getStore()->getId())->getWebsite()->getId()));

Magento give you not true website. Was too lazy to look for, as well as programmers Magento (getStore (true)) :)) so I decided to leave it

Upvotes: -1

sbditto85
sbditto85

Reputation: 1545

I realize this is old, but on a Magento 1.9.0.1 install i was having the same problem. I'm not sure what is happening but enabling the cache allowed it to work for me. Weird.

Upvotes: 1

Giuseppe Morelli
Giuseppe Morelli

Reputation: 46

With your informations is difficult to find the problem. Can you paste your system.log file?

One question: Do you have the compiler enabled? Try to disable it.

Upvotes: 0

Related Questions