Magento: Adding an RSS Feed

As you probably already know, Magento doesn’t offer any sort of news feed as standard and more Magento users are starting to use RSS feeds to help with their online presence.

In this tutorial I will show you how to add an RSS feed to your Magento shop.

To start with, you will need to create a phtml file called rss_feed.phtml in the following directory: app/design/frontend/default/your-theme/template/callouts

In this file you will need to add the following code to call up the RSS feed:

<?php $channel = new Zend_Feed_Rss(‘http://www.yourfeed.com/news/feed’); ?>
<?php $i = 0; ?>
<?php foreach ($channel as $item): ?>
<?php if ($i<3){ ?>
<?php echo $item->get_date(‘j F Y’); ?><br />
<p><?php echo $item->title; ?><br />
<a href="<?php echo $item->link; ?>">Read post »</a></p>
<?php } else { } ?>
<?php $i++; ?>
<?php endforeach; ?>

You will then need to change the URL to the URL of feed that you have set up in Feedburner.

Once you have done that you will need to open up the page.xml file in app/design/frontend/default/your-theme/layout/ and then find the block where you would like to add the news feed to.

Add the following code to the page.xml file:

<block type="core/template" name="latest.news" as="getNews" template="callouts/rss_feed.phtml"/>

Save this file and upload it with the rss_feed.phtml file.

Now you are ready to call the RSS in the main phtml pages and add the following code to the template files where you want the RSS to display:

<?php echo $this->getChildHtml(‘getNews’) ?>

Save, upload and then style it up to fit in with your shop design.

Related posts:

  1. Adding Free Sample or Tester Products in Your Magento Shop
  2. Magento: Create XML Blocks
  3. Magento Template Path Hints
  4. Magento: Changing The Favicon
  5. Magento: PHTML Files In Dreamweaver

Tags: ,

Leave a Reply


Contact Us Today...

If you have any questions about our services or want to arrange a free no obligation consultation contact us today or call 02920 290 080 for Cardiff and 01179 000 482 for Bristol.

Bit Torrent Study Discovers Most File Sharers Are Now Monitored

Ever heard of torrents or used Bit Torrent to download movies, music or shared files over the internet? Researchers have discovered that anyone who does use Bit Torrent to download files over the World Wide Web will most probably be monitored. Studies were carried out by Birmingham University and they have discovered that if someone [...]
» more

Cardiff: 02920 290 080 Bristol: 01179 000 482