WordPress and Magento integration extension

Wordpress Deluxe

Try WordPress Deluxe for a fully integrated solution for Magento CE and EE

You can now obtain a copy of the Magento WordPress Deluxe Extension. Our store isn’t live yet, so we are taking orders via email at the moment.

The price is £100 including free installation (theming is not included).

Buy WordPress Deluxe now!



Otherwise, here’s the old free version

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. With this extension, it is easy to facilitate your magento wordpress integration.

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.

Combining Magento and WordPress provides a big thumbs up for SEO, ease of use and performance.

So why use the WordPress Magento extension?

  • Includes breadcrumbs
  • Supports SEO Urls
  • Supports META tags
  • It is free! (we can also install it for you for a small fee)
  • It comes with a feed widget for both comments and posts *new
  • Now integrates Magento user’s profile for posting comments *new

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.2.1

  • 1

    First, download the files that you need
    Sonassi_Wordpress_Module.tar.gz
    Sonassi_Wordpress_Theme.tar.gz
    Sonassi_Wordpress_MagentoTheme.tar.gz
    WordPress.xml.tgz
    Generate_htaccess.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

    As people seem to be having difficulty identifying their server’s outbound IP address – we have put together a script to automatically create both .htaccess files – or amend as necessary. Download Generate_htaccess.tar.gz into your WordPress directory (/blog), then visit your website http://www.example.com/blog/generate_htaccess.php. This should automatically perform steps 5 and 6 for you.

    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.

    Extract WordPress.xml.tgz to ./app/design/frontend/default/default/layout. This file contains the XML for the extension, it has a default handle of blog_default that is applied to every page, this can be adjusted to suit your desired look.

  • 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

*This only applies to version 1.1 or lower

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();

allow_url_fopen is disabled

In this case, you will need to replace the function getPage() in Model/Page.php with the cURL alternative.

    public function getPage()
    {
 
      $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB).$_SERVER['REQUEST_URI'];
      $url = str_replace("//blog","/blog",$url);
 
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $url);
      curl_setopt($ch, CURLOPT_FAILONERROR, true);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_FORBID_REUSE, true);
      curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
      curl_setopt($ch, CURLOPT_MAXCONNECTS, 20);
      curl_setopt($ch, CURLOPT_MAXREDIRS, 2);
      curl_setopt($ch, CURLOPT_TIMEOUT, 5);
      $content_curl = curl_exec($ch);
      $response_curl = curl_getinfo($ch);
      curl_close ($ch);
 
      if ($response_curl['header_size']) {
          $type = $response_curl['content_type'];
          if ((strpos($type,"text/html") === false && strpos($type,"application/x-httpd-php") === false)
                 || strpos($type,"text/xml") !== false ) {
 
            if ($ch && $content_curl) {
              foreach ($response_curl as $header => $key) {
                header($header.":".$key);
              }
              echo $content_curl;
              exit();
            } else if ( strpos($type,"text/xml") !== false ) {
              echo $content_curl;
              exit();
            } else {
              header("Location: /no-route");
              exit();
            }
          }
 
          $this->buffer = $content_curl;
 
          return $this->buffer;
      } else {
        header("Location: /blog/");
        exit();
      }
    }

I’m stuck in a redirect loop

This is caused by either two things, incorrect request URL or the content-type being mis-read. Edit Model/Page.php and add the following lines instead:

   $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB).$_SERVER['REQUEST_URI'];
+ $url = str_replace("//blog","/blog",$url);
 //$type = end($http_response_header);
 $type = false;
 foreach ($http_response_header as $headerVal){
   if(stristr($headerVal, 'Content-Type') !== false)
   $type = $headerVal;
}

But I want to change the URL

That can easily be done by changing the following files:

In .htaccess change all blog > news.
In blog/.htaccess change all blog > news.
In app/code/local/Sonassi/Wordpress/etc/config.xml change blog > news.
In app/code/local/Sonassi/wordpress/Model/Page.php change blog > news.
In blog/wp-config.php, add

define('WP_HOME','http://example.com/news');
define('WP_SITEURL','http://example.com/news');

I’d also like to incorporate the WordPress feeds on my site!

Then you should read our guide on WordPress feed integration for Magento.

 

 

This entry was posted in Magento and tagged , , , , , , , , , , , , , , , , . Bookmark the permalink.

259 Responses to WordPress and Magento integration extension

  1. Hello Ben,

    First, thank you for providing this extention to the community.

    I installed it several times with different versions of Magento and WordPress. Unfortunately, I cannot get it to work.

    I have a double-page 404 error.

    I checked the intructions, htacess files were generated via php generator file provided here and I checked them to make sure they were as stated above. All is well, except it is not working.

    Can you shed a light in might seem to be the problem and how could i fix it?

    thanks

    Magento 1.3.2.4
    Wordpress 3.0


    • Hi Tico,

      This is a common bug, the URL in Page.php is malformed – it probably contains “//blog”, add a:

      $url = str_replace("//blog","/blog",$url);

      Under the $url declaration.


  2. Hi there,

    I’ve got this integration working fantastically with Magento 1.4, the only minor issue is the breadcrumb, it’s a bit untidy and reads like this when in a post:

    Home / Blog / Printing-leaflets-flyers-business-cards-folders / 2010 / 07 / Exhibitors-specials

    It’s technically correct but looks a bit iffy and dodgy. Is there a way of correcting this? I’ve tried ALL the breadcrumbs suggestions in this thread/reply section and all I get is parse errors. I’m pretty experienced in Magento but can’t quite suss this one.

    Any suggestions appreciated.

    Cheers


  3. Hi Armando,

    I sure do ;) If you want three independent blogs – you can use WPMU – our included WP template works with WPMU. Otherwise, just follow the standard instructions.


  4. Comments have been disabled as this extension has now been replaced by the far superior deluxe edition.