I have Magento CE installed and unaltered in my Uwamp localhost.

I was just casually testing some functions from the app/code/core/Mage/Core/functions.php file, by calling those functions in my root script as below:

require_once 'app/Mage.php';
ini_set('display_errors', 1);

echo Mage::helper('core')->__('any text to be printed');
echo Mage::helper('core')->now();

But when I called the now method of the same functions.php file, I got the below error:

Fatal error: Uncaught Error: Call to undefined method Mage_Core_Helper_Data::now() in C:\UwAmp\www\[magento-root]\test.php on line 11

I was astonished, confused and annoyed to find that even though functions.php actually contains the function now, it doesn't allow it to be called from any other file(or root script as in my case).

Please check here to ascertain that now function actually exists in functions.php file.

What on the earth could be possible cause for this weird scenario?


now() isn't actually part of the 'core' helper. It is a method inside of the app/code/local/Mage/Core/functions.php file that gets included in app/Mage.php like this:

include_once "Mage/Core/functions.php";

The correct way to call this would be:

echo now();

You don't need the Mage::helper('core') part since it's not actually part of the core helper and isn't even in a class at all.

You can verify this by adding your own method to Mage/Core/functions.php as a test.

I added:

function sean() {
    return 'test';

to the bottom of functions.php. I was then able to access it like this:

require_once 'app/Mage.php';

echo sean();

I ran the test file above and the result was test

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.