Ipsita Rout
Ipsita Rout

Reputation: 5179

Can Magento be integrated with CakePHP?

Can Magento be integrated with CakePHP? If my site is developed in CakePHP. Can I do the product module including shopping cart in Magento?

Upvotes: 5

Views: 2205

Answers (3)

Tanvir Gaus
Tanvir Gaus

Reputation: 205

I managed to do a hack (and there where no other way to do that).

The hack is you need to put the "function __()" inside in line 93 of Magento app/code/core/Mage/Core/functions.php

    if (!function_exists('__')) {
        function _ () { .... }
    }

and you need to do the same for "DS" in app/Mage.php line 23

    if(!defined('DS')) {}

then you can just use the Mage class and do all the operation to Megento.

Upvotes: 0

Tanvir Gaus
Tanvir Gaus

Reputation: 205

can make the Mage class working for me in pure php code with the above example. But you know Cakephp has its own routing mechanism. I have magento installed in the root and trying to add another application built with cakephp - that application has its own data structure & database (mainly be used for custom reporting and some tracking stuffs) but will share some data from magento (that is the main site)

Upvotes: 0

silex
silex

Reputation: 4320

Yes, it can. For example:

require_once 'app/Mage.php';
umask(0);

Mage::app();
Mage::getSingleton('core/session', array('name'=>'frontend'));

$cart = Mage::helper('checkout/cart')->getCart()->getItemsCount();
echo 'Items count: ' . $cart;

Look at these articles:

http://www.exploremagento.com/magento/run-magento-code-outside-of-magento.php

http://blog.chapagain.com.np/magento-how-to-run-magento-code-in-an-external-website/

Upvotes: 9

Related Questions