3

Is it possible to include multiple Magento (Mage.php) instances into the same external script and run them simultaneously?

My idea is to develop an external migration tool between two Magento systems, where entities from one instance will be directly transferred into the other one.

Normally I can load Mage via:

require_once('app/Mage.php'); //Path to Magento
umask(0);
Mage::app();

But can I do something like:

require_once('../old/app/Mage.php'); //Path to Magento (1st instance)
require_once('../new/app/Mage.php'); //Path to Magento (2st instance)
umask(0);
Mage::app();  //This would probably not work anymore, if I include more than one Mage.php?..

Does anyone have an idea?

2

I don't think this is possible. PHP can not have two classes with the same name in one script execution.

There are solutions out there for more generic PHP cases that will suggest to rewrite the class source or try to move the classes into namespaces, but with the Mage class in Magento this is impossible.

Throughout the whole core Magento code there are references to Mage in the form of static calls, like Mage::app(). PHP would not know which Mage to use (if it where possible to run both).

I suggest you use some form of in between data storage. You could first get all entity data from one system and put it into a database or object storage (or dump JSON to files). Then run the other system and pull the data from the data storage and save it to that Magento.

  • Thank you for the input, I'll try to do it like that and post my results here, if I'm successful. – QB new media Apr 22 '15 at 20:38

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.