I am using Magento (directory example.com/app) and WordPress (directory example.com/blog/wp-blog-header.php).

When I set up a WP_Query in Magento's template\catalog\product\view.phtml it shows the following error:

Fatal error: Cannot redeclare __() (previously declared in \app\code\core\Mage\Core\functions.php:93) in wordpress\wp-includes\l10n.php on line 98

Is there a way to get this to work?

  • 3
    what is the error? – Milo Nov 14 '12 at 1:09
  • Milo,do you know how to correct it? – 250091017 Nov 14 '12 at 6:04
  • Seems like magento is declaring functions using same names as WordPress. __ is a localization function in WP. interested if someone got a solution. – Z. Zlatev Nov 14 '12 at 7:35
  • This is in app/functions.php now. – fuxia Feb 2 '14 at 17:54

__() is deprecated in magento. You may either manually delete it from the magento core files (& repeat this process again everytime you have a new install or you upgrade) or wait for magento developers to remove this.

For wordpress, in the future when php 5.3 is much more common & wordpress breaks their backward compatibility & push all their code to namespaces then only this will be solved. I think this won't be anytime soon(maybe never?).

BOTTOM LINE: Since wordpress relies on this function for some functionality & it's deprecated in magento, go for deleting it from core files in magento. You already have the path & line number (\app\code\core\Mage\Core\functions.php:93)

If this doesn't work for you, you can't do what you asked for in the question. My suggestion for an alternative is to create a wordpress script which could dump the required information to some database then create a magento script to read it from there & run them individually (maybe setup a cron)

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.