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.
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! (we can also install it for you for a small fee)
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
Sonassi_Wordpress_Module.tar.gz
Sonassi_Wordpress_Theme.tar.gz
Sonassi_Wordpress_MagentoTheme.tar.gz
Wordpress.xml.tgz
-
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.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
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();
Last 5 posts in Magento
Dependant layered navigation filters in Magento
Custom attributes for categories in Magento
How to disable WYSIWYG on Magento 1.4
Magento 1.4 Install Errors
Even better Wordpress and Magento integration


laurent
24 Jan. 2010
Hi,
I ve got this error
Controller file was loaded but class does not exist
Trace:
#0 C:\wamp\www\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(306): Mage::exception(’Mage_Core’, ‘Controller file…’)
#1 C:\wamp\www\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(282): Mage_Core_Controller_Varien_Router_Standard->_inludeControllerClass(’C:\wamp\www\app…’, ‘Sonassi_Wordpre…’)
#2 C:\wamp\www\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(195): Mage_Core_Controller_Varien_Router_Standard->_validateControllerClassName(’Sonassi_Wordpre…’, ’standard’)
#3 C:\wamp\www\app\code\core\Mage\Core\Controller\Varien\Front.php(158): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#4 C:\wamp\www\app\Mage.php(459): Mage_Core_Controller_Varien_Front->dispatch()
#5 C:\wamp\www\index.php(65): Mage::run()
#6 {main}
ben@sonassi.com
24 Jan. 2010
Hi Laurent,
I would need to see the error in context to be honest – its difficult to diagnose without a complete trace and know exactly what you have done.
Plus, Windows isn’t an ideal test bed
8asic
25 Jan. 2010
We are using wordpress 2.9 and the lazzymonks extension. Any advice on migrating from the lazzymonks extension to this method? It seems to be a much better solution.
ben@sonassi.com
25 Jan. 2010
Hi 8asic,
The only real advice I could offer is to follow the installation instructions backwards for Lazzymonk’s extension – removal is the reverse of installation.
Or, install this alongside the Lazzymonks for the time being – as far as I know, it doesn’t share any common URLs or rewrites.
rdv
25 Jan. 2010
Guys,
This seems like a more elegant solution than the alternatives I’ve found. Unfortunately, I can’t get the news page to show the posts from Wordpress at all. I’ve installed as illustrated above. I’m using Magento 1.3.2.4 and Wordpress 2.9.1 (installed in its own db). The rewrites seem to work correctly, but the end result is that I get the 404 page whenever I try to access any of the blog pages. For example…
http://MyDomain.com/news – > 404 No Route page
http://MyDomain.com/news/uncategorized/2010/01/hello-world/ – > 404 No Route page
I know Wordpress is installed properly. I can access the admin panel and if I remove the rewrites from ./fetch-news, I can see the unstyled pages correctly. I think my problem may be related to getting Magento to do whatever it’s supposed to do with Sonassi_Wordpress_Module.
I’m afraid that I only know enough php to get myself into trouble. I would be happy to try to make changes based on your recommendations. Any help would be appreciated.
Regards,
rdv
ben@sonassi.com
25 Jan. 2010
Hi rdv,
That looks like the rewrite within Magento isn’t working then. Can you re-check you have performed steps 2, 7 and 8 – and (even though it is unlikely), refresh the Magento cache.
rdv
26 Jan. 2010
Thanks so much for the prompt reply. I came in this morning and just happened to reload the /news page and found that the test post showed up right away. I’ve started styling the output from the wordpress theme to look like the rest of my site.
Questions:
1. I can’t figure out how to get the menu into my layout. I am using a 2-column layout for the most part and would like the blog menu to show up at the top of the left col while the content is on the right. Any help customizing the menu would be greatly appreciated. I am interested in showing the last 10 articles, the archives and the tags.
2. One of the reasons to use wordpress for me is the ability to generate the sitemap.xml file via a plug in. I installed XML Sitemap Generator for WordPress 3.2.2 and that seems to be working fine. The sitemap shows the fetch-news version of the urls. I assume that the rewrite puts in a 301 to the news version. Is that correct?
3. How do you suggest showing the last X posts on the home page?
Found bugs:
1. You can’t have a category named News. This results in an extra replace with fetch-news that results in a 404 No Route Page.
Matt Smith
27 Jan. 2010
Thank you for this great extension. Can you please tell me if when the extension is installed will registered users of my magento store will be logged in with the same account on my wordpress?
ben@sonassi.com
27 Jan. 2010
I’m afraid not, this is just a simple integration.
I’m sure when one of our clients asks for it, we’ll develop it
Colin
28 Jan. 2010
Hi Ben,
I’m very excited about the prospect of using your integration.
I’ve gotten it installed on a remote linux host with Magento 1.3.2.4 and Wordpress 2.9.1.
When I go to http://www.mydomain.com/news, it waits, then times out with
Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.
I’ve triple-checked your installation steps, have caching turned off, and cleared both my magento and browser cache.
Something is obviously going on with the rewrites – the same thing happens with
http://www.mydomain.com/fetch-news
and
http://www.mydomain.com/fetch-news/index.php
Might you have some guidance?
Thanks!
ben@sonassi.com
28 Jan. 2010
Hi Colin,
Did you enter your server’s IP address in Step 5?
RewriteCond %{REMOTE_ADDR} !^XXX\.XXX\.XXX\.XXX
Colin
28 Jan. 2010
Yes. I’ve also tried commenting that line out altogether.
Oddly, this morning
http://www.mydomain.com/news/
doesn’t result in a wait and a 310 error, but rather Magento’s default 404 text.
Does that give you any more useful info?
ben@sonassi.com
28 Jan. 2010
Hi Colin,
That looks like the rewrite within Magento isn’t working then. Can you re-check you have performed steps 2, 7 and 8 – and (even though it is unlikely), refresh the Magento cache.
Colin
28 Jan. 2010
OK… rechecked steps 2, 7 and 8, and manually cleaned out var/cache and cleared browser caches.
I’ve got
app/
+code/
| local/
| Sonassi/
| Wordpress/
| +controllers/
| | StandardController.php
| +etc/
| | config.xml
| +Model/
| Page.php
+design/
| frontend/
| default/
| default/
| template/
| wordpress/
| content.phtml
| head.phtml
| left.phtml
+etc/
modules/
Sonassi_All.xml
I had also discovered that the RewriteBase line in
magento/.htaccesswas commented out, so I uncommented it and restored it toRewriteBase /
but it didn’t change the behavior after clearing caches again.
Perhaps I should put error_log statements in to see what (if anything) is getting rewritten? If you think that’s useful, where would you suggest?
Thanks
Colin
28 Jan. 2010
It looks like my situation has converged with rdv’s. I wonder if there is some other server/magento configuration that’s causing this.
Colin
29 Jan. 2010
Hi Ben,
I got it figured out.
At least under Magento 1.3.4.2, there’s an error in
/app/code/local/Sonassi/Wordpress/Model/Page.phpfunction:
getPage()line: 47,
in the call to
Mage::getBaseUrl().When fetching the page
http://www.mydomain.com/newsthe call to
Mage::getBaseUrl()is returninghttp://www.mydomain.com/index.phpwhich, when prepended to $loc becomes
http://www.mydomain.com/index.php/fetch-news/which isn’t a real magento URL, so it gets rewritten to
http://www.mydomain.com/news/and we’re in a redirect loop.
The call to
Mage::getBaseUrl()on line 47 should beMage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)which will return the URL without a trailing
index.php, and the constructed URL becomes:http://www.mydomain.com/fetch-news/instead of
http://www.mydomain.com/index.php/fetch-news/and then it works!
My question for you is:
There are 2 other calls to
Mage::getBaseUrl()ingetPage(). Should either of these be using theMage_Core_Model_Store::URL_TYPE_WEBparameter as well?Thanks for your integration!
ben@sonassi.com
30 Jan. 2010
Hi Colin,
Well observed! Given that we only installed it for our clients in the same environment – those rewrite issues didn’t occur.
I’ve made the changes to the package to suit your recommendation.
blaze
13 Feb. 2010
I’ve tried this on my localhost server.
the problem is I always get 404 error, although I already check following code.
$store = Mage::app()->getStore()->getCode();
and your configuration is useless when we want to rename it to /blog/ instead of /news/
we have to edit all the php and xml file within the Sonassi folder in app/code/local. but that doesn’t work either.
I don’t know.. maybe anybody can point me to the right direction?!
ben@sonassi.com
20 Feb. 2010
Hi Blaze,
The new version released is defaulted to /blog – so install that one instead and remove the changes from the previous version.
A 404 error or redirect loop is almost always the IP being wrong in both .htaccess files or the cache not having been refreshed.
Jay
18 Feb. 2010
I continue to get 404 errors. I have check all steps and repeated the install. Used all the info from this post and still 404.
I have changed $store = Mage::app()->getStore()->getCode();
If I remove the .htaccess from fetch-news I can see the raw unstyled pages. I assume it is a rewrite issue, but I can’t figure it out. I have the correct IP. And wordpress backend is fine.
Any advice?
ben@sonassi.com
18 Feb. 2010
Hi Jay,
It is difficult to say without looking at your implementation.
We do perform installations for customers, please get in touch if you need further assistance.
thebakermark
13 Mar. 2010
Hey Jay,
I see you got it working. I am having the same problem as you and was wondering how you fixed it.
Joe
18 Feb. 2010
This is a great little integration that you have developed. I have installed it on my web site and everything works except for posting comments. When I try to post a comment it just goes to the main wordpress page. One note is that I changed the directories from ‘news’ to ‘featured’ and from ‘fetch-news’ to ‘featured-tees’. I modified all of the Magento files, .htaccess files, and the wordpress config to make that directory work and it is working as far as posts showing up, but the commenting is not working. Any suggestions?
Thanks,
joe
ben@sonassi.com
18 Feb. 2010
Hi Joe,
I’ll need to have a test on our own versions – to be honest, I haven’t even tried to use comments!
Joe
18 Feb. 2010
Hi Ben,
Thanks! I will dig in a little and see if there is something that is preventing the comments from submitting. If I make any discoveries I will let you know.
ben@sonassi.com
19 Feb. 2010
Hi Joe,
I’ve released a new version of the extension that allows comments to function:
http://demo.sonassi.com/blog/uncategorized/2010/02/hello-world/
Follow the instructions from the beginning as some details have changed
Mike
20 Feb. 2010
Hello Ben just added you on skype, please contact me asap I’d like to get a quote to ad more feature to this extension
Kai
22 Feb. 2010
Hi there, thanks for your work. Works fine under Magento 1.4.0.1.
“Flush Magento Cache” and “Flush Cache Storage” in Magento helped against the 404-Problems.
Anyone got a solution to display blog posts or a list of latest posts on magento homepage or other pages, maybe in the sidebar?
ben@sonassi.com
22 Feb. 2010
Hi Kai,
That is pretty straightforward, you can just use simpleloadxml for the feed and parse it.
Lost
24 Feb. 2010
My server actually wrote over my .htaccess file again. Luckily, since I know what the problem is now, it was a quick fix. You may want to add to the directions to make your .htaccess files read-only when done. Thanks again guys.
ben@sonassi.com
24 Feb. 2010
Hi Lost,
I think I know what might have caused that. Wordpress uses its comments (#START WORDPRESS) as a file parsing mechanism so it can retain your changes whilst adding new ones from new plugins etc.
I have changed the .htaccess for Wordpress now to suit this (it was just tidier/smaller the previous way).
We’re glad you are enjoying the extension
Ollie kavanagh
25 Feb. 2010
Great plugin guys, I had the Lazzymonk one running after fiddling with Magento for a few hours. Backtracked and installed this in 10min! Really like having the proper permalinks.
One question, I am trying to work locally on my dev box, but how can I set the server IP? Setting
RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.1just gives me a blank page and commenting out these lines just sets me on a constant re-direct of http requests. Any ideas?ben@sonassi.com
25 Feb. 2010
Hi Ollie,
We were trying to help someone with a WAMP dev environment last night achieve the same thing.
But it isn’t *really* possible out the box as the server IP is the same as the client IP. If you get Apache to communicate on another device (NOT the loopback interface), then it will happily work.
Ollie Kavanagh
25 Feb. 2010
Thanks! I’ll see if I can work something out, strangely enough it worked at home for me last night just commenting out those lines. No idea why, but it has stopped working now at another office, weird!
Michael
25 Feb. 2010
Excellent post – well done!
I tried your solution and I manage to see posts but not wrapped around magento. My magento home is not the root of the domain “/” but it sits at “/how/”. What changes do I need to make for the magento module to kick-in?
Thanks,
Michael
ben@sonassi.com
25 Feb. 2010
Hi Michael,
A fair few, any instance of “/blog” will need to be changed to “/how/blog”
(off the top of my head) that includes,
config.xml
Page.php
.htaccess
Michael
25 Feb. 2010
Hi Ben,
Thank you very much for your immediate reply! I tried to replace all occurences of /blog with /how/blog (both .htaccess files, Page.php and config.xml) as suggested and now I cannot access the blog at all – I keep getting 404 errors.
I double-checked everything and I cannot find anything else that needs changing. It seems that magento is not redirecting /how/blog to index.php so that your module gets the request. I am not sure why though…
Any ideas?
Cheers,
Michael
ben@sonassi.com
25 Feb. 2010
Hi Michael,
Do you have
RewriteBase /howand
RewriteBase /how/blogAlso, make sure you refresh the cache after changing config.xml
Michael
25 Feb. 2010
Hi Ben,
This is what my .htaccess in /how/blog looks like:
RewriteEngine On
RewriteBase /how/blog
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/how/blog/wp-admin
RewriteCond %{REQUEST_URI} !^/how/blog/wp-content
RewriteCond %{REQUEST_URI} ^/how/blog
RewriteCond %{REMOTE_ADDR} !^91\.207\.220\.69
RewriteRule .* ../index.php [L]
# BEGIN WordPress
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
# END WordPress
Since I get the magento 404 page I guess it is not a redirect issue – magento doesn’t know where to find the /blog/* pages – so I guess I am doing something wrong with the magento addon.
Does this sound like a config.xml or a Page.phtml issue? Is there an easy way to debug this and figure it out?
Thanks so much for your help!
ben@sonassi.com
25 Feb. 2010
Hi Michael,
We would need to look at it ourself to see why it is not working, please get in touch.
Michael
25 Feb. 2010
Thank you for your help Ben. Unfortunately your mod is not working when magento is not at the root of the domain. There are rewrite issues as well as issues in generating the correct urls (eg getPage).
If someone has managed to install this on a site with magento in a folder please let us know how you did it!
Michael
25 Feb. 2010
I have managed to get things working… the main issue was with getPage code:
if (@$file = file_get_contents(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB).$_SERVER['REQUEST_URI']))
which I replaced with:
if (@$file = file_get_contents(’http://’.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']))
to avoid having my folder name “how” being put twice in the url and therefore ending in an infinite loop.
Very nice integration indeed Ben – well done!
Ron Suarez
25 Feb. 2010
I have a really simple question. Is step one to install Magento (i.e. before WordPress) and do they share the same MySQL database?
ben@sonassi.com
26 Feb. 2010
Hi Ron,
The guide assumes you have Magento installed already – so, yes, that would be step #0 (if there was one).
Wordpress and Magento do not have to share the same database if you don’t want them too.
Ken
26 Feb. 2010
Great mod! But how did you get the Wordpress sidebar into a block on Magento?
ben@sonassi.com
26 Feb. 2010
In StandardController.php:
Michael
26 Feb. 2010
Hi again. Any idea what handle I need to set in my layout files so I can change the sideboxes that appear on the left and right of the page?
ben@sonassi.com
26 Feb. 2010
Hi Michael,
Just for you, I’ve update the extension to use its own XML sheet properly, be sure to pay attention to the extra install step! [#7]
Ken
27 Feb. 2010
Hey, I was just wondering if you took a look at how it displays the RSS feed page. Even in your sample that you set up, it’s messed up. Displays the same as mine. Any ideas? Thanks.
ben@sonassi.com
27 Feb. 2010
Hi Ken,
I’ve fixed that for you now, re-download Sonassi_Wordpress_Module.tar.gz
Ken
1 Mar. 2010
Ben, well that fix worked to make the .blog/feed/ page show up correctly, but feeds for individual posts go to a no-route 404 page.
This extension is great. I’ve posted a link to your page from my site too.
Colin
3 Mar. 2010
Hi Ben,
I discovered your extension depends on the existence of the navigation breadcrumb (as our site doesn’t use the breadcrumb, and it broke when I took it out!). I added a check in StandardController.php to make sure $breadcrumbsBlock isn’t empty before using it, and that did the trick. Thought you might want this feedback for your next update.
Thanks for your work!
mccarrd4
6 Mar. 2010
Has anyone had any luck getting this to work when Magento is installed within a sub-directory and not in the root folder. For example domain.com/magento/. I get getting a Magento 404 inside the main Magento content area, where the blog content should be.
mccarrd4
6 Mar. 2010
Just read Michael’s comment. I replaced $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB).$_SERVER['REQUEST_URI']; with $url = ‘http://’ . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; in Page.php and this had solved my problem!
ram mendhe
8 Mar. 2010
Hi ,
I am using following versions
magento-1.4.0.1.zip
wordpress-2.9.2.zip
I have tried according to your instruction but its not working.
Please help me.
ben@sonassi.com
8 Mar. 2010
What aspect isn’t working?
thebakermark
12 Mar. 2010
I installed this successful on a site before but can’t get it to work on a new site. I checked every step and I keep getting redirect loop. My IP is correct. I refreshed the cache, deleted cache folder. My store is installed in / and wordpress is installed in /blog/
Here is my .htaccess for /
and /blog/.htaccess
Does anyone have any ideas. If the rewrites are correct what else will cause the redirect loop?
Magento ver. 1.3.2.4
WordPress ver 2.9.2
Running Litespeed
Oh yeah.. the IP address is correct!
ben@sonassi.com
12 Mar. 2010
I would need to see for myself I am afraid.
Ronal
14 Mar. 2010
I keep getting the 404 page, I have template folder in my default folder so i put in base. Could that be the problem?
ben@sonassi.com
15 Mar. 2010
Hi Ronal,
It sounds unlikely, more to do with Magento not picking up the rewrite.
ben@sonassi.com
27 Jan. 2010
For those that are getting stuck, if you want help with integration, get in touch for more in depth assistance.
What we will need is SSH/FTP/Magento Admin/phpMyAdmin details and the Store URL.