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(’’); ?>
<?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="" 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. Install Magento Locally On A Mac
  2. Magento: Create XML Blocks
  3. Magento: Changing The Favicon
  4. Magento: Translate Inline
  5. Magento Template Path Hints

Tags: ,

Leave a Reply

Contact Us Today...

For more information regarding any of our services or to arrange a free consultation simply send us a message or call 02920 290 080 for Cardiff and 01179 000 482 for Bristol.

Firefox 4 Beta

Mozilla have released the first beta version of Firefox 4. The latest version of this browser will include better support for many of the new web technologies, a new add on manager, crash protection from third party plugins and accelerated hardware support. One of the most obvious changes is that the tabs have now been moved [...]
» more

Cardiff: 02920 290 080 Bristol: 01179 000 482