Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); leads into a fatal error

A Magento extension I installed has a line of code that leads into a fatal error. I'm using Magento 1.8.0 and when I remove this line everything works like expected.

Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

Can somebody please explain what this line of code does and why its needed in the extension. After I commented this line out everything works fine and I couldn't find any kind of problem, but I'm a bit scarred that the problem will come up later.

Here is what the system log file throws:

2014-08-27T21:10:13+00:00 ERR (3): Warning: include(Mage/Default/Helper/Data.php): failed to open stream: No such file or directory  in /homepages/11/d460572798/htdocs/magento/lib/Varien/Autoload.php on line 93
2014-08-27T21:10:13+00:00 ERR (3): Warning: include(): Failed opening 'Mage/Default/Helper/Data.php' for inclusion (include_path='/homepages/11/d460572798/htdocs/magento/app/code/local:/homepages/11/d460572798/htdocs/magento/app/code/community:/homepages/11/d460572798/htdocs/magento/app/code/core:/homepages/11/d460572798/htdocs/magento/lib:.:/usr/lib/php5.4')  in /homepages/11/d460572798/htdocs/magento/lib/Varien/Autoload.php on line 93

I'm a complete newbie in programming of Magento.

like image 215
David Weber Avatar asked Mar 19 '23 15:03

David Weber


1 Answers

The code is use to set current store that using by Magento

Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

Magento uses store with id zero for admin side. Frontend may have any number of stores. So they don't have fixed store id. But admin side always has its store id zero and is fixed.

So the extension, due to some reason trying to use admin store forcefully. May be that line added in the extension during the development of the extension (for testing purpose). But not sure.

From the question, it is not sure where that code is using. So I cant say whether the code is essential or not. But if the problem solves when comment out that line and if there is no log errors present, you are good to go. Feel free to comment out that line.

The error that is showing in log errors are showing due to this line (A wild guess).

If you need more details, you need to ask this quesition to developers who created that extesnion :)

like image 162
Rajeev K Tomy Avatar answered Mar 21 '23 05:03

Rajeev K Tomy