Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9006081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:19:06+00:00 2026-06-16T01:19:06+00:00

I’m trying to write a block that loads the Magento shopping cart inside of

  • 0

I’m trying to write a block that loads the Magento shopping cart inside of a Drupal block.

The following code (located in /test.php) loads the shopping cart and its contents properly (Magento install located in /magento):

<?php
      /*
       * Initialize magento.
       */
      require_once('magento/app/Mage.php');
      umask(0);
      Mage::app('default');
      Mage::getSingleton('core/session', array('name'=>'frontend'));
      Mage::getSingleton('customer/session');
      /*
       * Add specific layout handles to our layout and then load them.
       */
      $layout = Mage::app()->getLayout();
      $layout->getUpdate()
          ->addHandle('default')
          ->load();

      /*
       * Generate blocks, but XML from previously loaded layout handles must be
       * loaded first.
       */
      $layout->generateXml()
             ->generateBlocks();

      /* 
       * Now we can simply get any block in the usual way.
       */
      $cart = $layout->getBlock('cart_sidebar')->toHtml();
      echo $cart;
?>

(I’m using FirePHP to debug session values — that’s what the fb(); calls are for.)

If I use that exact same code within Drupal (via a hook_menu callback), I get the following error:

Fatal error: Mage_Core_Model_Session_Abstract::getMessages(): The
script tried to execute a method or access a property of an incomplete
object. Please ensure that the class definition
"Mage_Core_Model_Message_Collection" of the object you are
trying to operate on was loaded before unserialize() gets called or
provide a __autoload() function to load the class definition in
/home/aendrew/workspace/drupgento/magento/app/code/core/Mage/Core/Model/Session/Abstract.php
on line 215

My guess is that Drupal’s doing some sort of session handling that’s conflicting with Magento’s — if I unset $_SESSION at the start of the script, it displays an empty cart (regardless of whether or not there are actually items in it). I’ve also tried putting the existing session in a temporary variable and then doing an array_merge() at the end, but that doesn’t work either.

Any idea how I can do this? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T01:19:08+00:00Added an answer on June 16, 2026 at 1:19 am

    I worked on an integration between Joomla and MAgento I get the same problem.
    The solution I provide is maybe not the best solution but it was the only one I found to share sessions between a single PHP script process.

    I had to “stop” the Joomla session, do my stuff with Magento and start again the session in Joomla all of it during the same script process. Here is a sample of what I did for a Joomla plugin, you can get an inspiration of that because I’m not aware of Drupal Framework but here you will find the code I did for the Joomla plugin: http://pastie.org/5505841#4

    The most interesting part in the code provided are the methods destroyTemporaryJoomlaSession, loadAndStartMagentoBootstrap, restartJoomlaSession, startMagentoSession and stopMagentoSession.

    Then I use this plugin in some Joomla module in this way:

    $plgMageLib = new plgSystemMagelib ( );
    $plgMageLib->destroyTemporaryJoomlaSession ();
    if ($plgMageLib->loadAndStartMagentoBootstrap ()) :
        $plgMageLib->startMagentoSession ();
    
        /* Content of Magento logic, blocks or else */
    
        $html = '';
        $blockId = $params->get ( 'block_id', '' );
        echo JFusion_Helper_Mageselectblock::callblock ( $blockId );
    
        /* EOF */
    
        $plgMageLib->stopMagentoSession ();
    
    endif;
    $plgMageLib->restartJoomlaSession ();
    

    Hope it helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to create an if statement in PHP that prevents a single post
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.