Magento Forum

RSS Blog Integration
 
leetaylordoes
Sr. Member
 
Total Posts:  227
Joined:  2008-02-05
San Diego, CA
 

Hey there,

My goal is to to integrate a blog into our site structure. I’m thinking for a cleaner solution at this point, and due to time constraints, simply publishing an RSS feed of our Wordpress blog (while re-skinning our Wordpress blog to match our Magento skin) would be the best idea.

Before we proceed:
1) Does anyone have any suggestion on a different solution for integrating a blog?

2) I believe this is possible, via creating a custom sidebar callout and publishing the RSS feed via that “module” - but I’m unsure as to whether or not there is a better implementation solution than this.

Your comments are appreciated.

 
Magento Community Magento Community
Magento Community
Magento Community
 
leetaylordoes
Sr. Member
 
Total Posts:  227
Joined:  2008-02-05
San Diego, CA
 

I went ahead and integrated an embedded blog feed to our site, and will soon customize a Wordpress blog to match our Magento skin. I hear there’s a stirring of a Wordpress/Magento Integration plugin coming? SSO functionality would be great - though I realize Magento is still growing from the foundation.

All kinds of praise to Magento coming from my end though. Thanks to everyone for the hard work on this…

 
Magento Community Magento Community
Magento Community
Magento Community
 
finch8243
Sr. Member
 
Total Posts:  79
Joined:  2007-08-31
 

Timothy—how exactly did you tweak Magento so as to display WP RSS feeds?  Did you edit one of the phtml files?

Thx

D

 
Magento Community Magento Community
Magento Community
Magento Community
 
Paaaaa
Member
 
Total Posts:  50
Joined:  2008-10-30
 

Hey Timo, how did u show the rss feed in magento? Explain?

 
Magento Community Magento Community
Magento Community
Magento Community
 
leetaylordoes
Sr. Member
 
Total Posts:  227
Joined:  2008-02-05
San Diego, CA
 

Hi All,

My apologies on the delayed responses here. There are a few ways you can actually implement this functionality. We once used an RSS aggregator (like Feedburner) that essentially displayed items via a new block we created in Magento on the client’s home page.

Using a third-party like this can be troublesome, especially when using Javascript to receive the actual feed items. Slow loading is a result. Thus, we’re thinking of writing or utilizing an existing PHP script to use on a webserver to draw in desired Feed items.

I’ll get back and post upon seeing if any alternative possibilities work more efficiently.

Thanks for the interest!
Lee

 
Magento Community Magento Community
Magento Community
Magento Community
 
leetaylordoes
Sr. Member
 
Total Posts:  227
Joined:  2008-02-05
San Diego, CA
 

Hi All,

Update, still haven’t written a quick PHP script to be used for displaying a feed on the frontpage. This is the route I’d recommend though, especially for quality loading time.

If anybody has time and is up for it, feel free to post it with directions up here!

Cheers,
Lee

 
Magento Community Magento Community
Magento Community
Magento Community
 
LostDocs7
Member
 
Avatar
Total Posts:  31
Joined:  2008-12-03
 

Hi all,

We developed extension for RSS parsing and placing on Magento pages: http://www.magentocommerce.com/extension/990

 
Magento Community Magento Community
Magento Community
Magento Community
 
jesse_dev
Jr. Member
 
Total Posts:  27
Joined:  2009-03-03
 

here’s some code for tying into Zend’s Feed class

<?php

//don't have to do any of this if it's a module, ie Mage and Zend are already loaded
define('APPLICATION_PATH'realpath(dirname(__FILE__))."/lib");
set_include_path(APPLICATION_PATH PATH_SEPARATOR get_include_path());
$loader='Zend/Loader.php';
require_once 
$loader;
Zend_Loader::registerAutoload();
$feed_path='Zend/Feed.php';
require_once 
$feed_path;


try 
{
    $rss 
Zend_Feed::import('http://www.wordpress_site.com/blog/?feed=rss2');
    echo 
"<br>".$rss->title();

catch (Zend_Feed_Exception $e{
    
echo "<br>Exception caught importing feed: {$e->getMessage()}\n";
    exit;
}

// Initialize the channel data array
$channel = array(
    
'title'       => $rss->title(),
    
'link'        => $rss->link(),
    
'description' => $rss->description(),
    
'items'       => array()
    );

// Loop over each channel item and store relevant data
foreach ($rss as $item{
    $channel[
'items'][] = array(
        
'title'       => $item->title(),
        
'link'        => $item->link(),
        
'description' => $item->description()
        );
}



?>
*update* i got pubDate and author to work by doing $item->whatever()
i’m not at work right now, i’ll update this if i remember
 
Magento Community Magento Community
Magento Community
Magento Community
 
skicrave
Member
 
Total Posts:  51
Joined:  2007-12-02
 

jesse_dev- If you happen to see this would you mind giving an example of how to use your code to actually display headlines on Magento pages?  I’m not understanding how to actually use the code you’ve posted to output html in the shopping cart.

Thanks,

Jason

 
Magento Community Magento Community
Magento Community
Magento Community
 
jesse_dev
Jr. Member
 
Total Posts:  27
Joined:  2009-03-03
 

yea sure, it has to be plugged in as a local module.
/app/code/local/Namespace/Modulename/
from there you have
./etc/config.xml
which looks like:

<?xml version="1.0"?>
<config>
    <
modules>
        <
Namespace_Modulename>
            <
version>0.1.0</version>
        </
Namespace_Modulename>
    </
modules>
    <global>
        <
blocks>
            <
modulename>
                <class>
Namespace_Modulename_Block</class>
            </
modulename>
        </
blocks>
    </global>
</
config>
and then the folder ./Block/
which has View.php, and looks like:
<?php

class Namespace_Modulename_Block_View extends Mage_Core_Block_Template
{
    
protected function _toHtml()
    
{
        $html 
parent::_toHtml();
        return 
$html;
    
}

    
public function getHttpResponseCode($url{
        $ch 
= @curl_init($url);
        @
curl_setopt($chCURLOPT_HEADERTRUE);
        @
curl_setopt($chCURLOPT_NOBODYTRUE);
        @
curl_setopt($chCURLOPT_FOLLOWLOCATIONFALSE);
        @
curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);
        
$status = array();
        
$status = @curl_getinfo($ch);
        return 
$status['http_code'];
    
}

    
public function loadRss() {

        
try {
            $rss 
Zend_Feed::import('http://www.mysite.com/blog/?feed=rss2');

        try 
{
            $rss 
Zend_Feed::import('http://www.mysite.com/blog/?feed=rss2');

        
catch (Zend_Feed_Exception $e{
            
echo "<br>Exception caught importing feed: {$e->getMessage()}\n";
            exit;
        
}

        
// Initialize the channel data array
        
$channel = array(
            
'title'       => $rss->title(),
            
'link'        => $rss->link(),
            
'description' => $rss->description(),
            
'items'       => array()
        );

        foreach (
$rss as $item{
            $channel[
'items'][] = array(
                
'title'       => $item->title(),
                
'link'        => $item->link(),
                
'description' => $item->description(),
                
'pubDate' => $item->pubDate(),
                
'creator'=>$item->creator()
            );
        
}
        

        $html
="<ul>";
        for (
$x=0;$x<4;$x++) {

            $rss_post
=$channel['items'][$x];
            
$title=$rss_post['title'];
            
$link=$rss_post['link'];
            
$description=$rss_post['description'];
            
$creator=$rss_post['creator'];
            
$pubDate=$rss_post['pubDate'];
            
$date=date("n/j",strtotime($pubDate));
            
$html .= "<li><span class='rss_text'>$date</span> <a class='rss_link' href='$link'>$title</a>  By: $creator</li>";
        
}
        $html 
.="</ul>";
        return 
$html;
    
}

}
in /app/design/frontend/yours/yours/template/catalog/product/view.phtml
add this:
<div id="rss_container">
{{block type="modulename/view" template="modulename/view.phtml" }}
</div>

need a template file too:
/app/design/frontend/yours/yours/template/modulename/view.phtml

<?php 

$url
="http://www.mysite.com/blog/";
$code=(int) $this->getHttpResponseCode($url);
if (
$code == 0{
    
echo $this->loadRss();
}
?>

finally, enable the module in file /app/etc/modules/Namespace_Modulename.xml

<?xml version="1.0"?>
<config>
    <
modules>
        <
Namespace_Modulename>
            <
active>true</active>
            <
codePool>local</codePool>
        </
Namespace_Modulename>
    </
modules>
</
config>

oh yea there’s a gotcha I almost forgot about. Magento/Zend is missing a file in most recent distros !!

/lib/Zend/Validate/Hostname/Com.php

<?php
class Zend_Validate_Hostname_Com implements Zend_Validate_Hostname_Interface
{
    
/**
     * Add Ã§ to the list of allowed characters
     *
     * @return string
     */
    
static function getCharacters()
    
{
        
return  '\x{00E7}';
    
}
}

there ya go smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
skicrave
Member
 
Total Posts:  51
Joined:  2007-12-02
 

Thanks for taking the time to write up that summary, I’ll work on packaging it up as a module for others that may be interested.

 
Magento Community Magento Community
Magento Community
Magento Community
 
cloudesign
Member
 
Total Posts:  32
Joined:  2009-06-02
 

Pushing through this problem myself, very interested in this.

I’d like to combine a new product and AW Blog feed into one feed… that way I can display both.

Is that even a good idea? Best practice?

I’ve found this link in my search: http://inchoo.net/ecommerce/magento/latest-news-rss-box-block/

 
Magento Community Magento Community
Magento Community
Magento Community
 
briandesp
Jr. Member
 
Total Posts:  18
Joined:  2012-05-11
 

on the view.php i am getting a syntax error on the last } line 69

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top