PHP Magento Tips

Powered by Blogger.

Run Magento Code Externally

Rate this posting:

If you are working with Magento then often you need to use Magento core functions and classes outside of the Magento platform. This can be easily achieved with the following lines of code.

ini_set('memory_limit', '-1');

define('MAGENTO_ROOT', getcwd());
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
require_once $mageFilename;
//Get current logged in user info
$coreSession = Mage::getSingleton('core/session', array('name' => 'frontend'));
//Get cart info
$cart = Mage::getModel('checkout/cart')->getQuote();

foreach ($cart->getAllVisibleItems() as $item) {
      $productName[] = $item->getProduct()->getName();
      $productPrice[] = $item->getProduct()->getPrice();

Tag : Magento
0 Comments On "Run Magento Code Externally"

Back To Top