Magento and worpress Integration

Magento and wordrpress integration.

Step by step guideline on magento and wordpress integration, How to custom fields in wordpress post and how to access wordpress custom fields in magento.

Step 1.  Download magento plugin called Fishpig .
Step 2. Fist  install wordpress on same pc if possible and then install Fishpig plugin.
Step 3:  Once plug-in is installed. Now get back to magento admin panel, In top menu you will see fishpig plugin menu just before system menu.
fishpig > settings here you have to provide wordpress database  connection details. Save them and you are done with magento and wordpress connectivity.
Step 4: Now If you want to assign blogs/post created in wordpress to the magento categories, product, etc.

Yuppie!!! we are done.

How to add custom fields to the wordpress Blog/ Post ?

Oh Yes, there is one plugin called “Custom Field Template”. Install it.
If you don’t know how to install wordpress plug-in, there are two ways we can install wordpress plugins.

1. Manual Installation:

Download a plug-in zip file from server and upload it under  “wordpress/wp-content/plugins/”;
in the path mentioned above “wordpress” is your  directory where in you have installed wordpress.

2. Automation through wordpress admin panel

Login to the wordpress admin panel “wp-admin” i.e. default one provided if not changed.  Then In left menu there is option called “Plugins”

Step 1: Search for option "plugins > Add New"
Step 2: search the plug-in you want to installed and click on install link and you are done !!.

How do i access wordpress custom fields in magento ?
Lets say you have created new field using plugin “Custom Field Template” and field name is “file_1”.  Now existing post / create new post and assign value for this field.

Now get data for wordpress custom field in magento (Quick and dirty hack in magento):
fishpig plugin is installed under  community folder  i.e. “magento/app/code/community/”.

Step 1:  Open file model class file for post i.e. "app/code/community/Fishpig/Wordpress/Model/Post.php".
Step 2:   Now add following function to the class
public function getBlogImages($postId) {
$select = Mage::helper('wordpress/db')->getWordpressRead();
$data = array();
$fieldNames = "'product_file' ";
if(!empty($postId)) {
$data = $select->fetchAll("SELECT meta_key, guid  FROM wp_postmeta pm, wp_posts wp WHERE post_id IN ($postId) AND meta_key in ($fieldNames)  AND pm.meta_value=");
return $data;
Step 3:   Lets say you want to show this image in product detail page ( template/ catalog/ product/view.phtml ).
$postId =  blog / post id in wordpress.
$post = Mage::getModel('wordpress/post')->load($postId);
$imageData = $post->getBlogImages($postId);

And you are done !!!.

Njoy !!!


Share this nice post:

7 thoughts on “Magento and worpress Integration

Comments are closed.