Strongly Emergent

What comes from combining humans, computers, and narrative

WordPress-Magento Integration Error

This is a quick pay-it-forward post to anyone else who was having the same problem, because when I searched Google for solutions, I didn’t come up with anything. I think it’s a bad thing when googling for the verbatim text of an error message produces nothing.

So: you’re running a Magento site, and you’re using the FishPig plugin to integrate WordPress into your site. You might end up in a nasty situation where the integration settings page in Magento is telling you that “Your blog URL (site address) matches your install URL (WordPress address). Please change your blog route or move WordPress to a different sub-directory” and that that’s a problem. It is. Things will 404 as long as that’s true. However, the closest thing you’ll find to help on the FishPig site is deeply obscure.

[An error that can happen when trying to integrate Magento and WordPress] The problem might look like this.

The basic problem is one of terminology. WordPress is designed to play well with others, and to be highly configurable. So it cares about two URLs (URIs if you’re picky). It cares about “the file path that my PHP files live in on the server, relative to the root of whatever site I live in (e.g. in Apache, the DocumentRoot)”, and it cares about “the public URL that I will respond to.” In the database, these are ‘siteurl’ and ‘home’, respectively, in the wp_options table. It can be tricky to disentangle these two URLs, but for many WordPress installs, setting them both to the same URL is good enough and gets everything working.

However, that’s not the case when you need to integrate a WordPress blog into Magento. For the FishPig plugin’s “fully integrated” level of operation— which is good stuff, the best way to run that plugin— the WordPress PHP files need to live in the same site as the Magento files (when using Apache, they need to both be in the tree that starts at the site’s DocumentRoot), and, contrary to the usual WordPress setup, the ‘siteurl’ and ‘home’ values must not be set to the same URL. This is where we run into problems. The WordPress control panel refers to the ‘siteurl’ value as the “WordPress address (URL)” and the ‘home’ value as “Site address (URL)”. The FishPig plugin’s error messages, as seen above, will tell you that they can’t be the same, and will tell you that the ‘home’/”Site address” value has to match the “blog route” variable” in Magento. However, you have to fill in the third part of the syllogism yourself, and remember to set the ‘siteurl’/”WordPress address” to the same value as the “WordPress path” variable in Magento.

The final puzzle-piece is URL rewriting - most WordPress installs try to do a little .htaccess magic, and it can be tricky to keep it straight. If it’s not working correctly, you can end up in a state where the WordPress install, including admin pages, is completely inaccessible from the web and you’ve got to move down a layer and throw queries directly at the database to figure out what’s going on.

I imagine that this is obvious if you know WordPress better than I do, and it probably seemed obvious to the FishPig folks. However, if you’re in the same position I was in, where the WordPress admin page has become inaccessible, and there are no changes you can make in the Magento admin page that can fix the problem, I hope that this helps you.