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. Hi,
    after my installation of the sonassi wordpress I have a “302 Moved Temporarily” error. It depedns on the first 10 rows in the ./blog/.htaccess file. If I delete this RewriteRule and RewriteCond commands I can see the content of the blog but no styles and no magento wrapper.

    Please can you help me?!

    Thanks


  2. hi, firstly thank you for your codes, but i have a problem, sou can you help me?

    http://www.serhatergun.net/vaporizerusa/

    http://www.serhatergun.net/vaporizerusa/blog

    i couldnt see blog as your demo site. What do you think about my problem.

    thanks for helpful comments…


  3. Can anyone provide a download link with .httaccess files from a workig installation ?
    I to have the double-page 404 when I visit /blog/.


  4. I’m running magento 1.4 and am having a weird issue – everything works, but on the page ./blog there is a duplicate site inside the post. My logo, header nav, and sidebars all are displayed twice

    I just did the same exact thing on an older build of magento and it worked perfectly…

    any ideas how I can fix?

    see what I mean here http://www.southsunbeads.com/blog


  5. nevermind I figured it out- I had a AW blog for magento installed which was creating a problem.

    Thanks for the great stuff!



  6. Yugesh

    Hello,

    I have followed each step of integration but my blog is unstyled without default magento theme.

    Blog url is http://127.0.0.1/demo-magento/blog/

    /.httaccess file

    RewriteBase /demo-magento/

    ############################################
    ## BEGIN 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} !^127\.0\.0\.1
    RewriteRule .* index.php [L]

    ## END sonassi.com wordpress extension

    /blog/.htaccess

    ## BEGIN sonassi.com wordpress extension

    RewriteEngine On
    RewriteBase /demo-magento/blog/

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !^/blog/wp-admin
    RewriteCond %{REQUEST_URI} !^/blog/wp-content
    RewriteCond %{REQUEST_URI} ^/blog
    RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.1
    RewriteRule .* ../index.php [L]

    # BEGIN WordPress

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . index.php [L]

    # END WordPress

    But its still just giving a unstyled blog page. Any help would be greatly appreciated.

    Thanks in advance.


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


  7. I’m getting a redirect loop error – firefox says: “Firefox has detected that the server is redirecting the request for this address in a way that will never complete.”

    this is only when I visit southsunbeads.com/blog

    any help for this issue?



  8. Jean-Marc Buytaert

    Hi!

    Does the Sonassi WordPress Magento extension work with Magento 1.4.0.1+ and WordPress 3.0?

    I’m new with Magento, (not WordPress though) so I’m asking because I don’t want to mess up all the Magento work I’ve achieved so far. I’ve already done a DB and FTP backup, but I don’t want to go through the hassle of reinstalling WP and Magento again.

    Thanks for letting me know!
    jm



  9. David

    Thanks for this wonderful module.
    I’ve successful used this on a Magento 1.4.1.0/Wordpress 2.9.2 installation. Just wondering if there are any plans to upgrade the code when WordPress 3 comes out (apparently tomorrow)? I’ve tried it with the current module but it seems to get in an infinite loop, with Magento complaining about “SQLSTATE[00000] [1040] Too many connections”.

    Thanks again.


  10. redirect loop

    agh I just haven’t been able to figure this out… when I have completed all the steps to install this extension, then visit mysite.com/blog, or any other frontend pages associated with wordpress, I am entered into a redirect loop and my browser times out.

    I am, however, able to access the backend of my wordpress site.

    Does anyone have any suggestions for what I can try to solve this? I have extended my knowledge of this as far I can and I have now reached the limit.

    Thanks!

    Nick


  11. Hi Ben,
    I did a 20th time the full process and it is absolutely not working for me, there is a loop making the blog unreadable… :( Can you help me, I’m really stuck?
    You can see it on this page: http://www.retourdesindes.com/blog/
    I’m sure the problem comes from htaccess files… but I did generate_htaccess.php many times and no way :(
    I use Magento 1.4.1, do you think it can be the problem?
    Thanks a lot for your help!
    Benoît


  12. Hi,

    I used your example to integrate wordpress, all was pretty easy but I modified your theme as per my design and changed all the codes.

    Now I am struck how do I call menus, cart, breadcrumbs. I am not a php programmer. Please advice how do I call them.

    Regards


    • Hi Vijay,

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


  13. Hi,

    I have totally changed your source code file to get my design working as per my magento design and now I am struck how to call menus, breadcrumbs. Please advice.

    Regards


  14. I have a question – does
    RewriteCond %{REMOTE_ADDR} !^XXX\.XXX\.XXX\.XXX

    matters for localhost ?

    I am using apache, my url is localhost/projectname.

    I am not a php programmer, any advice ?

    Regards


  15. http://demo.stormkimonos.com/news/

    this page is blank ? Any expert comments ?


    • What I understand is its not calling the header file, so all css & js are missing to get the design.

      Please advice why is it not calling the header file..

      Regards


      • Hi Vijay,

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



  16. eduardo

    can anyone check whats the problem, i get unstyled blog http://www.balainettoyage.com/blog/

    i follow all the instruction above. thanks

    Please help, magento 1.4.0 WordPress 2.8



  17. Ben Incani

    I presume this instruction is referring to the magento .htaccess file…

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

    I am getting the same looping problem as most of the other posts, unless I change the RewriteCond to NOT rewrite blog, but this is not a fix.

    RewriteCond %{REQUEST_URI} !^/blog


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


  18. Hi Ben, I have tried to get the module to work, but if you have a look at my website you will see there are 2 designs showing, one on top of the other, do you know what is needed to be done to remove this from happening?

    My site is http://www.hampshirebaits.co.uk/blog

    Thanks John


  19. Hello… I’m curious. I attempt this integration using Magento 1.4.1.0 and WordPress 3.0, and get a timezone error that is relentless as well as saying that the file can’t be found, which renders the entire site completely useless. Any guesses? I am not a PHP programmer and am unwilling to take simple minded guesses that may destroy a functional store.


  20. Hi,
    Thank you for this, it is a very useful extension. I’m having a few problem with multiple redirects as noted by some others which lead to apache spawning multiple threads and killing my server.

    I’ve temporarily taken out the .htaccess statements and found that the blog still works. I also added RewriteRule ^/(.*)$ http://www.domain.com/$1 [R=301,L] to permanently remove any malformed url with multiple slashes. This has cured the server overload problems but I find it still takes afew seconds to load the blog pages, probably because there are multiple large articles in the blog. Is there any way to load an extract first, then move the each article much like I do for RSS feeds?


    • Hi Peter,

      This is a nasty side effect of this extension. It was admittedly thrown together in haste, we have replaced it with the deluxe edition of the extension because of the overheads outlined above.


  21. Hi there,
    I Installed magento 1.4.x
    followed instructions above
    added few products but the blog link is not appearing in the menu bar
    also if I type http://127.0.0.1/www/project/blog/

    the page which appears is losing stylesheet

    can u please guide me where I am mistaken..

    thanks in advance

    Regards

    Amit Joshi


    • Hi Amit,

      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.



  22. Michael

    This is exactly what i have been looking for but its not working for me, as such.

    I am using it on a localhost with MAMP, WP.3.0 & Magento 1.4.1.0, following all the instructions, see that the .htaccess has been generated but when I goto http://localhost/blog it DOES bring the Magento home page but with a “404 Not Found 1″ error.

    I did notice however when using the generate_htaccess.php it did come up with some error. Here is one which I have just done buy deleting the .htaccess file with i the blog directory.

    Warning: file_get_contents(.htaccess) [function.file-get-contents]: failed to open stream: No such file or directory in /Users/Michael/Sites/blog/generate_htaccess.php on line 16
    .htaccess generatedMissing sonassi_wordpress code in .htaccess
    .htaccess generated

    It would be great if anyone has had the same problem and has found a solution

    Thanks
    Michael


    • Hi Michael,

      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.


  23. I’m running xampp on Win 7 64bit, and have the same issue as a lot of people here… although i don’t think this is OS related.
    I do think it is all about the IP address. I’m not sure how this works in a production environment but locally I’ve got the site hosted with the 127.0.0.1 IP, When I run the generate_htaccess.php script it changes the local IP to the IP assigned by my ISP which effectively resolves to my router and ends there.
    It’s my hunch this is where the problem lies since the script is setting an IP address that is not accessible it’s never going to resolve. Am I correct?

    If so this could mean for those having issues in a production environment (shared IP hosting), their DNS settings could be affecting the ability to use this feature?

    That kinda makes me wonder too if the XAMPP default site is interfering with resolving the address.

    Anyway, that’s where I’m at after 3 days of rebuilding xampp, mage, wp several times to no avail.

    I’m wondering also if this integration is viable in enterprise edition? I’m setting up a store that is most likely going to be need enterprise edition to link POS/Back Office tools so is this even worth spinning my wheels?

    Thanks for any replies!


    • Hi Jon,

      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.


  24. Also, when I change the IP in root htaccess to 127\.0\.0\.1 it pulls up the WP with just the blank theme (which is what this feature is trying to avoid I thought). Interestingly though if I change it to any other IP it goes into the loop just like with the outfacing IP set by the generate_htaccess.

    Am I supposed to create a page in Magento called blog and add static block or something? Or do I just add a link to mydomain.com/blog?

    Sorry for being another headache on the list of troubled users. I believe I have followed the instructions to the letter. Maybe there’s something fundamentally missing in my setup and obviously that is not within the scope of your posting, but even coming from the .net side of things, I understand the structure and logic behind what’s being explained here.

    If it matters:
    My vhost file is pointing to my site as the default site and the named site, created a new ssl in openssl for the domain, all seems pretty straightforward, but I’m still all loopy.

    Happy Canada Day eh!


    • Hi Jon,

      It could be a number of things, throw a few exits around in Page.php on the $url,$type to see what has been declared.

      And Happy Canada day to you too ;)


  25. Hi, I’ve installed your extension with wordpress 3.0 but when I browse to mysite/magento/blog/ I have a blank theme and I’ve tried following the instructions several times, still no luck. Magneto is installed in a sub domain, does that make any difference to the outcome?

    Any help would be really appreciated.


    • Hi Tee,

      This isn’t an issue with WordPress v3.0 – it is because Magento is not controlling the rewrite. I would suggest following the instructions again, or trying the deluxe edition.


  26. I was having a similar redirect loop that others have mentioned and only in a live environment (development and staging servers worked flawlessly).

    After ensuring several times that my IP address was correct, I found my issue.

    In line 85 of ./app/code/local/Sonassi/Wordpress/Model/Page.php is the following line:
    $type = end($http_response_header);
    Content-Type is not guaranteed to be in the last position.
    I replaced this with the following:
    $type = false;
    foreach ($http_response_header as $headerVal){
    if(stristr($headerVal, 'Content-Type') !== false) {
    $type = $headerVal;
    }
    }

    and everything seems to be working great.

    Also of note, make sure that you have allow-url-fopen set to true in your php config, as this solution won’t work without it.

    btw guys, clever solution to integrating wordpress! Aside from some minor launch issues seems to work wonderfully!
    Thanks!
    -d.


    • Hi Dylan,

      We have seen this issue before. It was to be fixed in the next release, but the extension has now been superseded by our deluxe edition – which removes the file_get_contents/curl calls altogether.



  27. kidalynch

    So if I would like to use this with the enterprise edition of magento my theme paths are not

    ./app/design/frontend/default/default/layout

    but
    ./app/design/frontend/enterprise/default/layout

    Will this be an issue if I put them in my enterprise/default path?
    Or will i need to modify that path somewhere?

    Thanks!


    • Hi,

      It shouldn’t be an issue, the paths are inherited from the theme you have defined for the store view.


  28. Hi Ben, how do we add some better styling to the blog, like you have with the nice calendar dates, I also want to remove the left column and just have a right column with blog categories, archive, links etc.

    Hope you can please help

    Regards

    John


  29. Hi Ben, I have managed to fix the design issues, still playing around, but got it sussed.

    One issue is with facebook like button, I need to add the following code between the tags. (already done on main magento site as facebook like buttons are working fine on product page, but not working on blog, so need to find where blog head tags comes from)

    Hope you can please help so I can enable xfbml method which enables users to post a comment on what they like.

    Thanks

    John



  30. Style broken

    Hello, Ben

    this is great extension.

    I installed it on my site, I used Magento 1.4.0.1 and WordPress 2.9.2.

    your extension is working on these versions?

    Regards,