Magento WordPress Integration for multiple Websites via sub-directories.

Using Lazzymonk’s dated Magento WordPress module and a WordPress community plugin called “Mage-enabler“. I am using subdirectories to have multiple Magento websites all into the same Magento installation. Everything seems to work fine until I noticed the WordPress URL’s only contained WordPress’s baseurl, and not Magento’s, causing the Website scope to be lost and the user being reverted back to the default website after clicking another link within the WordPress integration.

:arrow: My structure is similar to:

United States Magento URL:
/us/

United States WordPress Blog URL:
/us/blog/

United Kingdom Magento URL:
/uk/

United Kingdom WordPress Blog URL:
/uk/blog/

:idea: In app/code/community/Mage/Blog/controllers/IndexController.php after this line

if (Mage::getStoreConfig('blog/blog/enabled'))
      {

I added:

<?php
  # Base URL rewrites for WordPress - mb
  $baseurl = Mage::app()->getStore()->getBaseUrl();
  define('WP_HOME',$baseurl.'blog');
  define('WP_SITEURL',$baseurl.'blog');
?>

Which causes WordPress’s base URL to be set to Magento’s and not loose website scope.

This may also work with different setups for multiple websites within Magento. But I have not tested it with any other setup.

:idea: Another plus to using the Mage-Enabler WordPress plugin is the ability to call on anything from Magento into WordPress. Some examples would be pulling in a customers first and last name, or showing how many products are in the users cart, etc. :D

Possibly Related Posts: