tags:

views:

77

answers:

2

Hi, I have created an Ajax cart in magento although it is a little hacky. It's not in a module or that. All I'm doing is using a script in the root of app that initialise mage and works with it.

What would be the correct way in implementing this? Ie how can I get my Ajax calls to interact wiu magento through a my module?

A: 

You should define a module, first and foremost. Once you've done that, you need to create controllers and actions such that they return the data you're looking for, but not the frame of the page. Since you get to define layout of the page, this shouldn't be too bad.

At that point, wiring the JS to the new actions should be as simple as changing URLs to your new, cleaner URLs.

Joseph Mastey
thats so simple. Why didn't I think of that! Thanks.
David
No problem. Remember that if my answer is the "right" one, you need to click the checkmark next to it to mark it for others who might visit the site.
Joseph Mastey
A: 

In addition to what Joseph has advised you, it may be worthwhile to point out to you is that you will have to disable the existing javascript that magento is using on the catalog and product view pages. Typically i would just comment out the code which is in the template files. Not sure if there is a cleaner way of doing this? @Joeseph: any idea on this?

Bill
Commenting the template files would work. There may be a "removeScript" action to correspond to adding a JS file, but I haven't had the opportunity to dig.
Joseph Mastey