If you are an e-store owner, you might be finding it difficult to publish an audience-attractive content. No wonder product definitions/descriptions are a must but it isn’t essential if that sort of content will attract any loyal visitor. With Google becoming more sophisticated and social media becoming a dominant source of referrals, it is essential for the retailers of e-stores to gear up with content publishing, if they want to retain existing buyers as well as drive in new customers.
Magento can be utilized as blogging platform with some available add-ons but if one integrates a platform specifically for content publication then there are several advantages of it. Turning WordPress into an ecommerce store is surely possible but with Magento the retailer gets flexibility and functionality which is quite tough to be acquired on a platform designed for content management. The right way is to integrate the WordPress blog in your Magento store instead of installing WordPress separately, as the data you want requires synchronization. But both ways will be explained here.
Let’s first take a look at integrating a WordPress blog to a Magento store –
- Manual integration by inserting codes –
Insert the following code in your Magento index.php file –
By inserting this code the user will be able to utilize any WordPress functions in your Magento store. For instance – If you want to show a WordPress navigation menu in the header of your Magento store, you can add the code you are currently using for creating the nav menu in your WordPress site directly into page/template/html/header.phtml file that loads your Magento header.
- By using an extension –
Adding a WordPress blog to an existing Magento store with Magento WordPress Integration from FishPig extension is one of the best ways. This extension allows the e-store owner can maintain a consistent brand identity by using the theme of Magento store for WordPress blog without modifying any files on either Magento or WordPress installation. One can log-in to the WordPress blog through the Magento dashboard.
Since there are numerous extensions available for WordPress, it is chosen as an integration instead of the native Magento blogging solution. The extension also supports popular WordPress plugins like Yoast’s SEO plugin and Disqus comments.
Now let’s learn about Integration Magento with a WordPress site –
- Manual integration by inserting codes –
Basic Setup –
This integration requires more coding in comparison to the previous integration. If you want to use your Magento header menu in your WordPress site, the first step required would be using this code in your WordPress header.php file as below –
With this coding you get the Magento Mage.php file with all the core functionality for Magento. Now you can access Magento template blocks and can load them into your header.php file.
Loading Blocks –
Magento header block can be loaded by using the following code –
<?php// Get Magento Layout$layout=Mage::app()->getLayout();
// Update Default Blocks$layout->getUpdate()->addHandle(‘default’)->load();
// Generate the layout XML and blocks$layout->generateXml()->generateBlocks();
// Access the header block and convert to HTML$header=$layout->getBlock(‘header’)->toHtml();
// Echo header block to the pageecho$header;?>
You get default Magento layout and updated blocks that are setup under <default> XML tag. If you simply try to load the header block without inserting this code then certain blocks won’t load properly which are included in the default layout for the header or site. By completing this step the user gets an access to the header block by generating XML and blocks. After this, the block can be echoed in the WordPress page.
Sharing Session Information –
To get an access to Magento session information, you need to grab the Mage session singleton by using the following code –
When you initiate the Magento store into your WordPress page simply type this code after Mage ::app(‘default’). Ensure that you insert the code at right place as there are frontend (store user information such as shopping cart) as well as admin (back-end admin panel) sessions. In the frontend session, you will see the value which is your encrypted session ID that enable you to access things like shopping cart. Make sure that the path is set to ‘/’.
Resolving Session Headers Already Sent Issue –
After all this code, it might happen that you get an error message when loading the WordPress site which informs that the headers for the site have already been set. Generally, you require to overwrite the default behavior for app/code/core/Mage/Core/Model/App.php – it tries to send the HTTP header for ‘Content-Type’ but it is already sent by WordPress and therefore, an error occurs as headers can’t be sent twice. To resolve this issue, you need to send the ‘Content-Type’ header so that one can get an access to Magento session cookie on the WordPress site without any hassle.
- The Plugin Method –
You can use the Magento WordPress Integration plugin for integrating WordPress blog into your Magento site. This plugin enables users of WordPress as well as Magento to import Magento blocks into a WordPress theme and offers short codes in order to add Magento products to posts and images in WordPress. If you have an existing e-store based on WordPress and would like to integrate Magento products with a stress-free way then this plugin is a great method.
Though WordPress and Magento lack in some features when used separately, but when combined together they create an efficient, powerful and fluid website. So, you don’t miss you try it.