Magento E-commerce - SMF forums bridge files and code

Started by Andre N, December 06, 2009, 02:12:44 PM

Previous topic - Next topic

Andre N

Finally finished :)
Magento Bridge

Summary:
These files will fully integrate your Magento E-commerce with your SMF Forums.

Features:
Login, logout, register, change email, change password, forgot password, activate, delete member, mass delete members. If the member does not exist in the other system they will be created when they login.

Known Limitations:
When a Magento admin logs into SMF, they will NOT be logged into the Magento admin panel automatically. I don't know how to securely do this yet until I have a chance to extend the Magento API. Otherwise the integration is complete and tested with every feature working as far as I know.

Versions tested:
SMF versions 1.1.10, 1.1.11
Magento versions 1.3.2.1, 1.3.2.4
It should work on most if not all SMF 1.1.x and Magento 1.3.x and possibly earlier versions. If you are able to successfully use this on any version of these softwares not listed above *PLEASE* leave a comment so your version can be added to this list. It will not work with SMF 2 without modification to the 2 magentoBridge files and the api file.

System requirements:
The system requirements for Magento can be found here. They are MUCH higher than the minimum or even recommended system requirements for SMF so just worry about Magento. You will need SOAP V2 also.
I used 2 separate databases but 1 should work if you use different prefixes. Both installations must be on the same server.

Installation:

Step 1- Create an API user in Magento. Here are step by step instructions on how to do this. Here is another set of instructions if you need it.

Step 2- Modify line 102 of magentoBridge.php to include your domain and path to Magento.
$proxy = new SoapClient('http://www.yourdomain.com/magento/api/v2_soap/?wsdl');
Modify line 103 of magentoBridge.php to include your API username and key you created in Step 1.
$sessionId = $proxy->login('API username', 'API key');
Modify line 105 of magentoBridge to include your path to Magento's Mage.php file. If it is not correct, the script will try to locate it for you but that will make things slow. Just set it now:
$path_to_magento = $_SERVER['DOCUMENT_ROOT'].'/magento/app/Mage.php';
If you installed it under /magento then don't worry about it; just add the API info.

Step 3- Upload magentoBridge.php, magentoBridge2.php and smf-magento_api.php to your forum root (probably /forum unless you specified another path). They must be in forum root for this to work. While in forum root path, download SMF's index.php file and add the following line to it just under <?php:
require_once($_SERVER['DOCUMENT_ROOT'].'/forum/magentoBridge.php');
Make sure this is the actual path to your forum root.

Step 4- Unzip the app folder. Open it up and navigate to /app/code/local/Magentobridge/config.php you will need to modify:

$GLOBALS['APIpath'] = $_SERVER['DOCUMENT_ROOT'].'/forum/smf-magento_api.php';

Make sure it represents your path the the smf-magento_api.php file. If your forum is installed in /forum you don't need to change anything here.

Step 5- Upload the app folder and it's contents to your Magento root folder. There should be a folder named 'app' already there but don't worry, this will not replace any of those files in any of your folders.

Step 6- Log into Magento admin panel and clear the cache, then click save. This is located in 'System'->'Cache Management'.
In 'System'->'Configuration'->'Web'->'Session Cookie Management' set 'Cookie Domain' to be '.yourdomain.com' (put the '.' before the domain name). Set 'Cookie Path' to be '/'. After you test things out be sure to turn your cache back on to speed things up a little.

Step 7- In SMF admin panel, in 'Server Settings'->'Feature Configuration' uncheck 'Enable local storage of cookies'. Check 'Use subdomain independent cookies'.

You should be all set at this point. Test it out and post any problems below. I'll check on this thread as often as possible. Please post bugs, issues etc. so I can make this better.

Planned future upgrades:
As time permits I'll be extending the Magento api to allow login/logout/activate without the need for the magentoBridge2.php file and that cookie. I'll also use Magento's event dispatch, similar to SMF's event hooking where possible to eliminate possible problems that could occur if you install too many mods with too many overrides. It shouldn't be an issue unless you've integrated Magento with something else that uses overrides.

Warnings:
Magento is a beast. It is great when it's set up but very tedious to customize. If you had trouble setting up SMF, Magento is definitely not for you.

A very big thank you to Moinul at Magento 4U who was kind enough to write the customer email/password change API override module for me as I had extreme difficulty with it. His site has loads of info on customizing Magento and if you need to hire a Magento developer I cannot recommend him strongly enough.

Any suggestions, comments, etc on this would be very welcome. Good luck  :)
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

Norv

Cheers, nice job! I'm sure Magento and SMF users will find it handy.
To-do lists are for deferral. The more things you write down the later they're done... until you have 100s of lists of things you don't do.

File a security report | Developers' Blog | Bug Tracker


Also known as Norv on D* | Norv N. on G+ | Norv on Github

Andre N

thanks! I have the Magento to SMF half working like a charm :)
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

Andre N

#3
This is nearly complete. I'll attach a full working version by the end of this week
And set up a demo site
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

studygroup

Quote from: ike turner on December 06, 2009, 02:12:44 PM
This SMF-Magento bridge is still in progress. As of right now it functions like this ...

Hi Ike,

I hope that you could give me a few tips as well, since I need a bridge from cmsms to smf. From what I read so far, if feels that it should be possible to leverage your code to a large extent and that is my only option as I am very new to web development and PHP altogether.

I need to figure out how to make the proper function calls to create, login/logout and update cmsms users in(to) smf, and that's exactly what your script does for Magento, right?

Thanks,
Oleg

Andre N

You could probably use the api file as-is if your cms application has only email address in common with SMF as Magento does. Or you could use the api in the downloads->tools area here which might be a better starting place. Include that (require_once probably better idea) in your cms file before using any of the functions. Just after they log into the cms, call the log in function. do that for every action
The Magento bridge file would work too going in the other direction, but you would need to modify every single function specifically for your cms. Then you include that in your smf index.php file and you are set.
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

studygroup

Thanks a lot, - sounds simple enough. I will try and let you know how it went.

Does "cms application has only email address in common" imply using email address in place of a user name? That is the way it's currently setup in my case.

Thanks,
Oleg

Andre N

That's what I meant. In Magento there is no username so the only commonality between the accounts is the email address. If you've got that the functions in the api will work fine for you with little modification.
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

Andre N

#8
Finally done. Marking as solved  ;)
edit - Demo site here: http://www.clubeventphotos.com if you want to try it out.

"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

denialls

hello,


            That is really great. you done a great job and it is quite simple this will help many cmsms users and also others. i was also facing some problem in this but now i understand that. so, thanks for sharing this information.


thanks!!
______________



Norv

I'm not sure I understand the question... the files can be found attached to the first post. They have been made available by ike turner, as per the first post.
Please, in case this answer does not address your question, perhaps you can explain more clearly what you are referring to?
To-do lists are for deferral. The more things you write down the later they're done... until you have 100s of lists of things you don't do.

File a security report | Developers' Blog | Bug Tracker


Also known as Norv on D* | Norv N. on G+ | Norv on Github

albertphilippe

So sorry, I wasn't logged so I can't download files.. All is Ok now.

Norv

To-do lists are for deferral. The more things you write down the later they're done... until you have 100s of lists of things you don't do.

File a security report | Developers' Blog | Bug Tracker


Also known as Norv on D* | Norv N. on G+ | Norv on Github

Andre N

A note:
If you plan on using anything besides instant registration, you'll need to move the integrate_register function to the bottom of the registration function in order to make it work properly. Otherwise, as-is from the smf side, it will register them in Magento and redirect. By moving the integrate_register function to the end it will do the smf registration first, then do magento, then redirect. If anyone needs help with the specific code for this let me know.
:)
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

magentobridge

thank you  ike turner

very nice work

was searching for a integration of any forum board software into magento without success yet
there is vb module wich costs 150 for example

and a free os jfusion but this requires joombla too and makes some troubles as it's not stable yet

thanks a lot for the time of developing this  :)

magentobridge


Andre N

How is it failing with 1.4? What  doesn't work?
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

magentobridge

the whole thing
but nevermind erased magento1.4 and installed fresh 1.3.3

Version tested:
SMF version 1.1.11
Magento version 1.3.3.0

thats working fine



I added you on yahoo. Need a little info for this code :)

Andre N

It *should* work for 1.4 too. I believe I had it working for one site, but the theme I had purchased didn't work so I installed 1.3.2.4 instead. I don't think the api changed enough to break it, but ok.

What code info would you like? Post it here so anyone else who is interested can reference :)
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

Advertisement: