ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Best way for Magento and EE to co-exist?

May 08, 2009 4:09pm

Subscribe [7]
  • #1 / May 08, 2009 4:09pm

    jtnt

    137 posts

    I have a site that for the most part will be run via Magento, since it’s an online store.

    However, they will have a few things - a blog, events, etc. - that I plan to use EE for.

    Since both systems run via an index.php file at the root of the web server, what would be the best way to have these systems co-exist? Anyone ever install and run both on the same site?

    Initial thought is to install them both as normal, and just change the EE index.php file to something else - then hide it and the Magento index.php file via .htaccess. Does this sound doable?

    I’d prefer not to run the EE via a subdomain, FWIW.

    I’ve been told before to install EE into a subdirectory (e.g. /blog), but this is sub-optimal as it ropes me into this structure down the road.

    So, any input here is appreciated. TIA.

  • #2 / May 12, 2009 11:01am

    jtnt

    137 posts

    Does anyone have any thoughts on this? Regardless of Magento being the other piece of software, does the concept I describe below seem plausible? Any ideas?

    Thanks.

  • #3 / May 12, 2009 11:42am

    Peter Lewis

    280 posts

    I know you mention about installing EE into a sub-directory and “this is sub-optimal as it ropes me into this structure”, but that’s assuming you use “/blog” (e.g.) as the URL surely?

    What I mean is why not use both?  Install EE into “/blog” subdirectory but re-write the path to it in htaccess - so whenever the user access a page say /blog/my-cms-page, you re-write this to be /my-cms-page.  The index.php page for EE doesn’t have to reside in root if you’re already using a system to captch the user (e.g. Magento).

    I’ve read up on integrating Magento with WordPress, and by default that installs into a sub-folder called “wordpress”, but using htaccess can mask that folder, so surely the same can be done for EE.

    Or maybe the other way around - where EE is the primary website, and Magento is the “add-on” in a subdirectory.

    In theory this should work!

  • #4 / May 12, 2009 11:46am

    Joe Michaud

    154 posts

    EE allows you to rename the index.php.

    Check in [ admin | system preferences | general configuration ] for a field that will allow you to rename it.  I believe you must also rename the file via ftp (EE will not rename it for you).

  • #5 / May 12, 2009 11:56am

    Peter Lewis

    280 posts

    How will Magento know to hand over to EE as the default page will always be index.php.  I assume you’ll always have to target the EE content with “www.blah.com/eeindex.php/my/path”, which you could re-write in htaccess to hide the ee-index.php…?

  • #6 / May 12, 2009 12:09pm

    Joe Michaud

    154 posts

    I’m not at all familiar with magento so I can’t be of any help in that arena.

    Here are a couple of points that may be worth considering, though:

    - You CAN move the index.php into a directory without too much trouble.  Look at the docs for the multiple site manager for the modifications you will need to make to the path.php file.

    - Depending on your server configuration, or with a little .htaccess magic, you can rename the index.php to something without the .php extension.  In this case, it will look and act pretty much like you had installed EE into a directory.

  • #7 / May 17, 2009 12:34pm

    jtnt

    137 posts

    Ok, back on this. What I’ve done is installed EE into a subdirectory -> /cms

    So, going to a default install page URL looks like: example.com/cms/index.php/site/getting_started/ (Where “site” is the template group.)

    I thought it would be pretty easy to remove the “cms/index.php” bit, so I could just go to example.com/site/getting_started, but I have some other Magento stuff in there I needed to work around, so my .htaccess file looks like the below. Note that the Magento stuff works fine, it’s just when I try to access the EE stuff that things don’t work (I get a 404 error, not run through Magento or EE):

    # Magento Rewrite stuff
    
    RewriteCond $1 !^(index\.php|media|media-center|skin|js|admin|downloader|robots\.txt|cms|favion\.ico|site)
    RewriteRule ^(.*)$ /index.php/$1 [L]
    
    
    ## EE Rewrite Stuff
    
    RewriteCond $2 ^(site)
    RewriteRule ^(.*)$ /cms/index.php/$2 [L]

    I’m hoping/guessing I’m just overlooking something sort of silly here. Any help?

  • #8 / May 17, 2009 12:43pm

    jtnt

    137 posts

    Yep, it was something silly. Don’t know why I changed the $1 to a $2 for the EE stuff, but that’s the issue.

    Proper code:

    # Magento Rewrite stuff
    
    RewriteCond $1 !^(index\.php|media|media-center|skin|js|admin|downloader|robots\.txt|cms|favion\.ico|site)
    RewriteRule ^(.*)$ /index.php/$1 [L]
    
    
    ## EE Rewrite Stuff
    
    RewriteCond $1 ^(site)
    RewriteRule ^(.*)$ /cms/index.php/$1 [L]
  • #9 / May 17, 2009 1:27pm

    Peter Lewis

    280 posts

    Now if you sort out how to share users between EE and Magento let us know!

    😊

  • #10 / May 17, 2009 1:28pm

    jtnt

    137 posts

    Baby steps, my friend. 😉

  • #11 / Sep 27, 2009 1:11pm

    Brian Litzinger

    704 posts

    I just put my magento site in a sub directory, e.g. /store/, then in the /store/app/Mage.php file I added the following line to the include paths:

    $paths[] = '/home/USER/public_html/system/templates/global/';

    Then I was able to include my main site’s header and footer files, so the Magento site instantly has the same styles and layout available to it. Every page in the /store/ section runs through the 1column.phtml file, so the change was easy, and at the top of that file I have the following code:

    <?php 
    $mage_head_content = $this->getChildHtml('head');
    $mage_page_title = str_replace(' - Default Store View', '', $this->getLayout()->getBlock('head')->getTitle()); 
    include 'header.php';
    unset($mage_head_content);
    unset($mage_page_title);
    ?>

    Fortunately I don’t have much EE template logic in my header, but it does look like this:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    
    <html >
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    
        <title>
            <?php echo (isset($mage_page_title)) ? $mage_page_title . '- ' : '
                {if embed:mysection == "home"}
                    Home - 
                {if:elseif embed:page_title != ""}
                    {embed:page_title} -             
                {if:elseif segment_2 == ""}
                    {exp:weblog:entries weblog="{embed:mysection}" url_title="{segment_1}" limit="1" disable="member_data|trackbacks|pagination" sort="desc"}
                        {title} - 
                    {/exp:weblog:entries}
                {if:else}
                    {exp:weblog:entries weblog="{embed:mysection}" limit="1" disable="member_data|trackbacks|pagination" sort="desc"}
                        {title} - 
                    {/exp:weblog:entries}
                {/if}'; 
            ?>        
            Site Title
        </title>
        
        <!-- JS and CSS includes here -->
        
        <?php echo (isset($mage_head_content)) ? $mage_head_content : ''; ?>

    That big conditional is kinda ugly, but it allows me to use the same header and footer for EE templates, and in my Magento store, and it passes the page title of the store items, and all the necessary JS Magento needs to that header template. Sure I could have managed 2 different header files, but that would be a pain, and this solution wasn’t that hard.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases