|
Just a quick one to let you know that I solved this one!
The working Cooliris wall can be seen here: http://beaumonaco.com/bracelets.html
and the feed itself is at: http://beaumonaco.com/rss/catalog/category/cid/35/store_id/1/
It required 2 modifications to the Core code.
The first, to get the thumbnails and images up to 400x400px, was to
app/code/local/Mage/Rss/Block/Catalog/Category.php
Around line 111, add this line:-
$imgLink=$this->helper('catalog/image')->init($_product, 'thumbnail')->resize(400, 400);
And in the block beneath that where $description is defined, change the block of code to:-
$description = '<table><tr>'. '<td><a href="'.$_product->getProductUrl().'"><img src="' . $imgLink .'" border="0" align="left" height="400" width="400"></a></td>'. '<td style="text-decoration:none;">'.$_product->getDescription(). '<p> Price:'.Mage::helper('core')->currency($_product->getPrice()). ($_product->getPrice() != $final_price ? ' Special Price:'. Mage::helper('core')->currency($final_price) : ''). '</p>'. '</td>'. '</tr></table>' ;
Which basically just puts the new image into the description.
The next change is a bit fiddly, but I added it to the Zend RSS feed builder:-
lib/Zend/Feed/Rss.php
On or around line 400, AFTER this block of code:
$description = $this->_element->createElement('description'); $description->appendChild($this->_element->createCDATASection($dataentry->description)); $item->appendChild($description);
I added the following code, in order to include some additional elements in the resulting feed:
$description2 = $this->_element->createElement('media:description'); $description2->appendChild($this->_element->createCDATASection($dataentry->description)); $item->appendChild($description2); /* media:thumbnail processing */ // extract all <img> tags and place in an array. Should just be one for each description preg_match_all('/<img[^>]+>/i',$dataentry->description, $imgresult); $thumb=$this->_element->createElement('media:thumbnail'); // Extract the "src=" portion of the resulting image attribute preg_match_all('/(src)=("[^"]*")/i',$imgresult[0][0], $img); preg_match('/"([^"]+)"/', html_entity_decode($img[2][0]), $noquotes); // strip the starting and ending quotes $thumb->setAttribute('url', substr($noquotes[0],1,-1)); $item->appendChild($thumb); // Using the same image as the thumbnail $content2= $this->_element->createElement('media:content'); $content2->setAttribute('url', substr($noquotes[0],1,-1)); $item->appendChild($content2);
And finally I added some more code at the end, in the saveXml function:-
Change it as follows, to add 2 new namespaces to the feed:-
// Content namespace $root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:content', 'http://purl.org/rss/1.0/modules/content/'); // existing line - added 2 below $root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:media', 'http://search.yahoo.com/mrss/'); // AJF added media namespace $root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:atom', 'http://www.w3.org/2005/Atom'); // AJF added media namespace
Thats about it! I know it’s not recommended to edit core Zend code, but I couldn’t think of an easier way due to the short timescale for my project. If anyone can think of a better way then I would be interested in seeing it
|