Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Both code examples above work fine. The problem I had was calling session_start() near the top of the CodeIgniter index.php file. Once that was removed, it all started working.</p> <p>For posterity, here is a Magento 10 Library for CodeIgniter 2.1:</p> <p>application/libraries/magento.php</p> <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit("No direct script access allowed"); Class Magento { function __construct($params) { global $site_root; $name = $params['name']; // Include Magento application require_once ($site_root . '/store/app/Mage.php'); umask(0); // Initialize Magento and hide sensitive config data below site root // Uncomment next line if you have moved app/etc // $options = array('etc_dir' =&gt; realpath('../magento-etc')); Mage::app('default','store', $options=null); return Mage::getSingleton("core/session", array("name" =&gt; $name)); } } // end of magento.php </code></pre> <p>Usage example app/model/test_mage.php</p> <pre><code> &lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Test_mage extends CI_Controller { function __construct() { parent::__construct(); $params = array('name' =&gt; 'frontend'); // frontend or adminhtml $this-&gt;load-&gt;library('magento', $params); } public function index() { $session = Mage::getSingleton('customer/session'); $magento_message = 'Welcome '; // Generate a personalize greeting if ($session-&gt;isLoggedIn()) { $magento_message .= $session-&gt;getCustomer()-&gt;getData('firstname').' '; $magento_message .= $session-&gt;getCustomer()-&gt;getData('lastname').'!'; } else $magento_message .= 'Guest!'; echo $magento_message . '&lt;br&gt;'; } } // end of test_mage.php </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload