I have been tasked with putting a store into a ready built site. the site has it's own custom CMS that is used to generate all the site's content (blogs, events etc..).

I intend to set the store base url to be mysite.com/store/ and the rest of the site would live at mysite.com/blogs/ , mysite.com/shows/ etc... as it currently does.

My problem lies in that the site has fixed header bar design which will now contain LOGIN / SIGN UP links as well as a shopping cart icon with the stored number of items in the cart above it (like Amazon). Also, it is not possible for me to utilise the Magento CMS for the rest of the site.

Is there a way to access the cart contents from the same domain (database?) but outside of the Magento install? And even logged in user details?


EDIT : I have looked into using the SOAP API to query the customer and the cart contents but it appears I would need the cart_id (quote_id ??).

Is it possible I could store the Cart ID in a $_SESSION variable after a user has added something and access that in the rest of my site, if so, where would I need to do this?

Questions like this seem to hint at hacking the core code, which I would have thought is out of the question.

2 Answers 2


The solution to this is quite broad and might be a bit of a challenge. Actually we had a discussion about this at an event in Berlin this weekend and the conclusion was that it's a lot of work and there aren't any standard, good, solutions.

There are several options like retrieving the data you need via an ajax call from the store and displaying that in the CMS or including the entire store header in some way but again, noting that simple.

  • Thanks for reading @Sander but it is not in Wordpress.
    – Mark
    Commented Mar 9, 2015 at 16:05
  • ahh sorry, I misunderstood then. In that case only the last line doesn't apply, the rest still does. It might be easier to read content into Magento via CMS pages for example Commented Mar 9, 2015 at 16:10

Someone answered this for me over on StackOverflow


Here is the code from that answer if anyone needs to do a similar thing. This file is in the root of my website outside of my domain.com/store/ Magento install.

    // Path to Mage inside of Magento install
    require_once( 'store/app/Mage.php' );


    // This has to run to authenticate customer and checkout session calls.
    Mage::getSingleton('core/session', array('name' => 'frontend'));

    // Get any customer model you desire.
    $oSession = Mage::getSingleton( 'customer/session' );
    $oCustomer = $oSession->getCustomer();
    $oCheckout = Mage::getSingleton( 'checkout/session' );
    $oQuote = $oCheckout->getQuote();

    var_dump( $oCustomer );
    var_dump( $oSession );
    var_dump( $oQuote );
    var_dump( $oCheckout );

    $oCart = $oQuote->getAllItems();
    if( !empty( $oCart ) )
        foreach ( $oCart as $oItem ) 
            $sName  = $oItem->getProduct()->getName();
            $fPrice = $oItem->getProduct()->getPrice();
            var_dump( $sName );
            var_dump( $fPrice );

I am also using


To show whether the user is logged in to the store or not.

Admin Config Settings

Inside of the Magento backend Admin > Configuration > Web > Session Cookie Management > Cookie Path to / and also that 'Use SID On Frontend' is set to Yes.

Note that if you required to do this on a subdomain you would need to set Cookie Domain to .mydomain.com

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.