One key feature that is only available in WordPress when using FishPig's WordPress Integration is Magento product and WordPress post associations. Using the extension, it is possible to relate products with posts and have them cross linked on both the product and blog post pages! This has obvious SEO and usability benefits and is so easy to implement, that your only excuse not for already doing is that you don't know how (hence this article)!
To associate some WordPress posts with a Magento Product, login to your Magento Admin and find the product you wish to use. Next, select the tab labelled 'Associated Blog Posts' from near the bottom. This tab should reveal a product grid that works identically to the related products grid. By default, the grid will show all posts currently linked to the product. If this is the first time you have been on this tab, it will display nothing as you have not yet made any associations. To associate posts, follow these steps:
- Modify the grid to show all posts. To do this, change the select field from 'Yes' to 'Any' and click the orange 'Search' button. This should now reveal all WordPress posts.
- Using the checkbox to the left of each post, select which posts you want to associate.
- When you have made your selection, select 'Save' from the top right hand corner.
By default, the related product block will show in the left column of your blog post page. To change this, you will need to change the block reference, which can be found in wordpress.xml. On your product page, related posts will be listed in the product.info.additional block. Again, this can be changed in wordpress.xml
To manually display them, you can do so using the following code:
Display associated posts on a Magento Product page
<?php echo $this->getLayout() ->createBlock('wordpress/post_associated') ->setTemplate("wordpress/post/associated.phtml") ->setTitle('Related Blog Posts') ->setEntity('product') ->setCount(5) ->toHtml() ?>
Display associated products on a blog post page
<?php echo $this->getLayout() ->createBlock('wordpress/post_associated_products') ->setTemplate('wordpress/post/associated/products.phtml') ->setTitle('Related Products') ->toHtml() ?>
Associating a Magento product with a WordPress category is a quick way to associate that product will all WordPress blog posts in that category and does not directly relate products and blog categories.