When we met in the morning we weren’t even sure what exactly to try out but soon agreed on implementing a Symfony authentication which uses the Magento customer database.
Starting our hacking, the first problem appeared quickly with incompatible class loaders: Unfortunately, the Magento class loader isn’t designed for missing class files, so every time Symfony tries to check for existence of a class which doesn’t exist there will be a fatal error. As we knew this problem from other projects a patch was already at hand.
Everything went quite smoothly then as integrating Magento into another project is basically just including the file
app/Mage.php and then calling
Implementing the authentication itself seemed easy too as there is this simple method call in Magento which we added to our bundle within minutes to try out the login:
But that’s where things got ugly: The sessions didn’t sync between Magento and Symfony. Integrating Magento without synced sessions doesn’t really make any sense as the user will loose his cart as soon as he browses from Magento to Symfony.
After a few hours of debugging and digging into both session handlers of Magento and Symfony the problem was found inside the
__destruct methods. So here’s what happens:
session_write_close()and saves the session content to the database (depending on your Magento configuration).
SymfonyComponentHttpFoundationSession::__destruct()writes its own session information with the key
_symfony2into the session storage – too late!
The solution was to add a
kernel.response event listener and call
SymfonyComponentHttpFoundationSession::save() so the Symfony session content gets into the session storage before Magento saves it to the database.
After solving the ugly session problem the only thing left was implementing an security provider for Symfony which authenticates the user against the Magento customer database. The result is a proof-of-concept Symfony Bundle which already provides some useful features to Symfony:
Integrating Magento into Symfony has been proven certainly possible and we had fun learning more about the session handlers of both Magento and Symfony.
At the moment there’s no specific project at Liip planning to use this bundle, so contribution is welcome on GitHub: https://github.com/liip/LiipMagentoBundle
Is there any way that magento development can allow export of orders/transactions to Quickbooks, preferably without a new module? This could be a direct sync or a simple excel/csv export that I can then import to Quickbooks.
At the moment thereâs no specific project at Liip planning to use this bundle, so contribution is welcome on GitHub: https://github.com/liip/LiipMagentoBundle
Is future development planed for this?
How to import Magento Products Without moving the program? I dont want to transfer the old website to the new server.
It’s great article. Thanks for sharing such great helpful information. Keep posting.
Very cool! Good luck with the bundle! sure to give it a spin in the future!
Great work guys! That was way cool!
Very interesting blogpost! Thanks for the experience sharing!