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.

 

 

  • http://www.sonassi.com ben@sonassi.com

    Hi Seth,

    You might benefit from the easier installation of the deluxe edition.

  • http://www.sonassi.com ben@sonassi.com

    Hi Vijay,

    I’m afraid I couldn’t tell you, you haven’t really provided a link to your implementation.

  • http://www.sonassi.com ben@sonassi.com

    Hi John,

    Nice layout, which talented Magento web agency did you pinch that from ;)

  • http://www.sonassi.com ben@sonassi.com

    Hi Ben,

    The loop is commonly caused by the wrong $url with //blog being present. It can also be caused by the content-type not being the last header, a fix has been posted by another commenter.

    Otherwise, you could try the deluxe edition.

  • http://www.sonassi.com ben@sonassi.com

    Hi Vijay,

    I think you have mis-understood the extension. There is no requirement to change the source.

  • http://www.sonassi.com ben@sonassi.com

    Hi Vijay,

    There wasn’t a step to change the source code – I would suggest following the instructions again :)

  • http://www.sonassi.com ben@sonassi.com

    Hi Be,

    There is a few common faults/fixes. I will update the main post with means of repair.

    Otherwise, check out the deluxe edition.

  • http://www.sonassi.com ben@sonassi.com

    Hi Nick,

    There is a few common faults/fixes. I will update the main post with means of repair.

    Otherwise, check out the deluxe edition.

  • http://www.sonassi.com ben@sonassi.com

    Hi David,

    Your wish has come true, check out the deluxe edition

  • http://www.sonassi.com ben@sonassi.com

    Hi Jean,

    Both the standard and deluxe edition work with 1.4 and WordPress 3.0

  • http://www.sonassi.com ben@sonassi.com

    Hi Yugesh,

    It outright will not work on a localhost server because the server IP is the same as the request IP. Unless you change the listening interface of Apache – it will always fail to work.

    You could try the deluxe edition which now bypasses all known issues.

  • http://www.sonassi.com ben@sonassi.com

    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.

  • http://www.sonassi.com ben@sonassi.com

    Hi Ovidiu,

    The .htaccess is unique to each installation.

  • http://www.sonassi.com ben@sonassi.com

    Hi Serhat,

    I would suggest getting in touch if you need our personal attention.

  • http://www.sonassi.com ben@sonassi.com

    Hi Markus,

    I would suggest getting in touch if you need our personal attention.

  • http://www.sonassi.com ben@sonassi.com

    Hi Pedro,

    We do have a release that uses cURL – but to be honest, this extension has been completely replaced by a far more reliable, fully featured version, check out the deluxe edition.

  • http://www.sonassi.com ben@sonassi.com

    Hi Raul,

    I believe we got you up and running again!

  • http://www.sonassi.com ben@sonassi.com

    Hi Be,

    That is a common issue, I’ll post the fix at the top of this post to help others.

  • http://www.sonassi.com ben@sonassi.com

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