Integrate Wordpress and Magento

Last modified by Sonassi Hosting & Design on Fri, June 25, 2010 09:57
Source|Old Revisions  

This is an old revision of the document!


The information in this article was correct at the time of writing, however, links to external files will be continually updated, so it is reccomended you view original article at www.sonassi.com.

Introduction

We’re not trying to re-invent the wheel here, nor are we going into any depth of connecting the authentication modules. From a front-end standpoint, the two “elements” wordpress and magento are essentially one – but all administration is carried out via either separate admin.

Where our solution works better than the others (Lazzymonks or ActiveCodeline), it actually allows the clean search engine optimised URL’s from Wordpress to be used in Magento’s breadcrumbs and address bar. It also takes advantage of Magento’s standard caching functionality, so the speed is very impressive. We also integrated the “Pages” listing in the sidebar with that of the Magento CMS, so you can use Wordpress for posts and still retain the Magento CMS for pages.

Why

So it provides a big thumbs up for SEO, ease of use and performance. So why use it?

  • Includes breadcrumbs
  • Supports SEO Urls
  • Supports META tags
  • It is free!

Installation

Installation might not be that straightforward as we developed it purely for a quick and clever wordpress / magento intergration, so we’ll try to explain as best we can!

This was tested and used with Wordpress 2.8 with Magento 1.3.2.4 and Wordpress 2.8 with Magento 1.4.0.0 at the time of writing

Current version: 1.1.0

  • 1

First, download the files that you need they are available here

    Sonassi_Wordpress_Module.tar.gz
    Sonassi_Wordpress_Theme.tar.gz
    Sonassi_Wordpress_MagentoTheme.tar.gz
  • 2

Make a new directory ./app/code/local/Sonassi then install the Sonassi_Wordpress_Module.tar.gz by extracting the tar file, then put the directory “Wordpress” in to a new folder ./app/code/local/Sonassi.

  • 3

Download and install the latest version of Wordpress from http://wordpress.org/latest.zip. Extract to ./blog (you can also change this, but you will need to change the blog reference throughout) and install Wordpress as normal.

  • 4

Extract Sonassi_Wordpress_Theme.tar.gz into the ./blog/wp-content/themes directory and select the Magento Wordpress 1.0 by Sonassi as the active theme.

In Settings > Permalinks set custom structure with /%category%/%year%/%monthnum%/%postname%/ for SEO.

  • 5

Edit ./blog/.htaccess and add the following information at the start, replace the XXX section with the outbound IP address of your server. This is to prevent the un-styled raw pages from Wordpress ever being displayed or indexed.

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /blog/
     
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !^/blog/wp-admin
    RewriteCond %{REQUEST_URI} !^/blog/wp-content
    RewriteCond %{REQUEST_URI} ^/blog
    RewriteCond %{REMOTE_ADDR} !^XXX.XXX.XXX.XXX
    RewriteRule .* ../index.php [L]
    </IfModule>
     
    # BEGIN WordPress
     
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . index.php [L]
    </IfModule>
     
    # END WordPress
  • 6

Update your ./htaccess to allow Wordpress to work, add this just beneath RewriteBase /

    ############################################
    ## sonassi.com wordpress extension
    ##
     
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_URI} !^/blog/wp-admin
        RewriteCond %{REQUEST_URI} !^/blog/wp-content         
        RewriteCond %{REQUEST_URI} ^/blog
        RewriteCond %{REMOTE_ADDR} !^XXX.XXX.XXX.XXX
        RewriteRule .* index.php [L]
  • 7

Extract Sonassi_Wordpress_MagentoTheme.tar.gz to ./app/design/frontend/default/default/template . We deliberately left these files almost empty – so you can customise them to your needs.

  • 8

Create a new file ./app/etc/modules/Sonassi_All.xml to enable the Wordpress module

    <config>
      <modules>
        <Sonassi_Wordpress>
          <active>true</active>
          <codePool>local</codePool>
        </Sonassi_Wordpress>
      </modules>
    </config>

That should be it, add some example posts, then visit your news on the front end via www.YOURDOMAIN.com/blog/ . We must stress that this Magento wordpress extension was never designed for mass installation – it was a quick one off for a customer that turned out to rival (if not better) the alternatives out there.

We’ve set up an example at http://demo.sonassi.com/blog/ – from following the directions above, we haven’t themed any element of it so you can see how it will look from the onset.

What’s going on, I keep getting redirected to the 404 page

On around line 163 of ./app/code/local/Sonassi/Wordpress/Page.php, there is a call to grab the current store code. We liberally assumed that “default” would be your default store name, if it isn’t, then it will cause 404 redirect errors.

Simply change it to,

$store = Mage::app()→getStore()→getCode();


View the original guide on how tointegrate Wordpress and Magento




 

Magento 2 GitHub Repository

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs