To make this a valid RSS Feed I adapted the code a bit...
This is displaying:
Copyright
Language
Date Timestamp
Shop Logo
SEO Links
Product images (can be auto resized find "->resize($product['image'], 80, 80)" and change 80, 80 to what ever you want. Rss maximum allowed width 144/ height 400. )
Product price
Product description
Validates on http://validator.w3.org/feed/
Feeds are working for Facebook (Notes and RSSGraffiti)
Demo Feed can be seen here http://www.caprice-modeschmuck.de/index ... oducts_rss
Facebook Page here http://www.facebook.com/pages/Caprice-M ... 3201793290
copy and replace code in replace the code in catalog/controller/feed/latest_products_rss.php with the code below
Code: Select all
<?php
class ControllerFeedLatestProductsRSS extends Controller {
public function index() {
if ($this->config->get('latest_products_rss_status')) {
$output = '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";
$output .= '<rss version="2.0">' . "\n";
$output .= '<channel>' . "\n";
$output .= '<title>' . $this->config->get('config_name') . '</title>' . "\n";
$output .= '<copyright>' . 'Copyright (c) ' . date("Y") . ' ' . $this->config->get('config_name') . ' All rights reserved.' . '</copyright>' . "\n";
$output .= '<link>' . HTTP_SERVER . '</link>' . "\n";
$output .= '<description>' . $this->config->get('config_name') . ' Latest Products Feed' . '</description>' . "\n";
$output .= '<language>de-DE</language>' . "\n";
$output .= '<pubDate>' . gmdate("D\, d M Y H:i:s T") . '</pubDate>' . "\n";
$output .= '<image>' . "\n";
$output .= '<title>' . $this->config->get('config_name') . '</title>' . "\n";
$output .= '<width>142</width>' . "\n";
$output .= '<height>18</height>' . "\n";
$output .= '<link>' . HTTP_SERVER . '</link>' . "\n";
if( $this->config->get( 'config_logo' )
&& file_exists( DIR_IMAGE . $this->config->get( 'config_logo' ) ) ) {
$output .= '<url>' . HTTP_IMAGE . $this->config->get( 'config_logo' ) . '</url>' . "\n";
}else{
$output .= '<url> </url>' . "\n";
}
$output .= '</image>' . "\n";
$this->load->model('catalog/product');
$this->load->model('localisation/currency');
$this->load->model('tool/image');
$this->load->model('tool/seo_url');
$limit = $this->config->get('latest_products_rss_limit') ? $this->config->get('latest_products_rss_limit') : 100;
$products = $this->model_catalog_product->getLatestProducts($limit);
if (isset($this->request->get['currency'])) {
$currency = $this->request->get['currency'];
}
else {
$currency = $this->currency->getCode();
}
foreach ($products as $product) {
if ($product['description']) {
$output .= '<item>' . "\n";
$output .= '<title>' . html_entity_decode($product['name'], ENT_QUOTES, 'UTF-8') . '</title>' . "\n";
//$output .= '<link>' . HTTP_SERVER . 'index.php?route=product/product&product_id=' . $product['product_id'] . '</link>' . "\n";
$output .= '<link>' . str_replace('&', '&', $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/product&product_id=' . $product['product_id'])) . '</link>';
$special = $this->model_catalog_product->getProductSpecial($product['product_id']);
if ($special) {
$price = $this->currency->format($this->tax->calculate($special, $product['tax_class_id']), $currency, FALSE, TRUE);
} else {
$price = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id']), $currency, FALSE, TRUE);
}
$p = htmlspecialchars('<p><strong>Price: ' . $price . '</strong></p>');
//$output .= '<description>' . $p . $product['description'] . '</description>' . "\n";
$output .= '<description>';
if ($product['image']) {
$output .= '<a href="' . str_replace('&', '&', $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/product&product_id=' . $product['product_id'])) . '">' . "\n";
$output .= '<img src="' . $this->model_tool_image->resize($product['image'], 80, 80) . '" border="0"/></a>' . $p . $product['description'] . '</description>' . "\n";
} else {
$output .= $p . $product['description'] . '</description>' . "\n";
}
$output .= '</item>' . "\n";
}
}
$output .= '</channel>' . "\n";
$output .= '</rss>' . "\n";
$this->response->addHeader('Content-Type: application/rss+xml');
$this->response->setOutput($output, 0);
}
}
}
?>