Post by tomtom » Mon May 09, 2011 7:30 pm

Note: This is adapted from the original Module from krikey here http://www.opencart.com/index.php?route ... order=DESC i wanted to post the code in the comments but it only allows 1000 characters max :choke:

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);
	}
    }
}

?>

New member

Posts

Joined
Sun May 23, 2010 8:28 pm

Post by FT Industriels » Sat Sep 03, 2011 4:23 am

Thank you it's work perfectly

Do you plane to upgrade it for OC 1.5.1.x ?

OC 1.4.9
IX WEB Hosting
Matériel industriel Maroc



Posts

Joined
Sat Jul 09, 2011 2:35 am
Location - Morocco

Post by tomtom » Sat Sep 03, 2011 5:43 am

Well, I have not switched over to 1.5 yet, but if I do I will and post it here.

New member

Posts

Joined
Sun May 23, 2010 8:28 pm

Post by phatmaxi » Wed Nov 30, 2011 3:25 am

working on an update

Newbie

Posts

Joined
Mon Nov 28, 2011 5:49 am

Post by straightlight » Mon Dec 05, 2011 6:35 am

Now compatible with v1.5.1.x (to avoid the error messages on screen). As for the content sides, a bit more work may be required.

Attachments

Compatible with v1.5.1.x


Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by phatmaxi » Wed Dec 07, 2011 1:29 am

Last edited by phatmaxi on Wed Dec 07, 2011 2:22 am, edited 1 time in total.

Newbie

Posts

Joined
Mon Nov 28, 2011 5:49 am

Post by straightlight » Wed Dec 07, 2011 1:38 am

If you're referring to my ZIP file above, the feed folder is not what has been specified as a folder from my package. Although, I can't neither reproduce the error you're encountering nor having a line 73 on the file since it rathers ends on line 59 ...

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by phatmaxi » Wed Dec 07, 2011 2:26 am

straightlight wrote:If you're referring to my ZIP file above, the feed folder is not what has been specified as a folder from my package. Although, I can't neither reproduce the error you're encountering nor having a line 73 on the file since it rathers ends on line 59 ...
Not sure what you mean, my intention was to replicate the original extension and I accomplished that. The errors were from my playing around with the code. But the actual link is updated and valid. The goal is the have a starting point were we can all create a really nice rss feed. I have minimal php skills, this took some work for me. Check out the link:
http://rrautomotivegroup.com/shop/index ... oducts_rss



What's Missing from the original is the SEO and Specials price... didn't have time to figure it out.

Attachments

My code for reference...

Last edited by phatmaxi on Wed Dec 07, 2011 3:03 am, edited 2 times in total.

Newbie

Posts

Joined
Mon Nov 28, 2011 5:49 am

Post by straightlight » Wed Dec 07, 2011 2:29 am

It's a bit clearer now that not only a URL has been posted. ;)

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON


Post by phatmaxi » Wed Dec 07, 2011 2:35 am

sorry for jacking your thread tomtom
Last edited by phatmaxi on Wed Dec 07, 2011 4:44 am, edited 2 times in total.

Newbie

Posts

Joined
Mon Nov 28, 2011 5:49 am

Post by phatmaxi » Wed Dec 07, 2011 2:36 am

straightlight wrote:It's a bit clearer now that not only a URL has been posted. ;)
:) awesome

Newbie

Posts

Joined
Mon Nov 28, 2011 5:49 am

Post by FTIndustriels » Sun Dec 11, 2011 4:59 am

Thank you for this modification.
I need to use url seo, do you know how can I do that ?

Quincaillerie, Fourniture industrielle Maroc
Opencart 1.5.1.3 French edition.
IX web hosting


Newbie

Posts

Joined
Wed Jul 27, 2011 3:48 pm
Location - Morocco

Post by FTIndustriels » Wed Dec 14, 2011 10:33 pm

Any one can do that for us ?

Quincaillerie, Fourniture industrielle Maroc
Opencart 1.5.1.3 French edition.
IX web hosting


Newbie

Posts

Joined
Wed Jul 27, 2011 3:48 pm
Location - Morocco

Post by barryhung » Mon Dec 19, 2011 12:45 am

I install the model successfully in 1.5.1.3 , but can't enable it always. anyone know why?

Newbie

Posts

Joined
Mon Dec 19, 2011 12:39 am

Post by barryhung » Mon Dec 19, 2011 12:49 am

I found the code in controller $this->config->get('rss_status') and anyone know where is the config I can found, DB or cache file?

Newbie

Posts

Joined
Mon Dec 19, 2011 12:39 am

Post by straightlight » Mon Dec 19, 2011 1:08 am

In the setting table's value field from PHPMyAdmin, you will probably see it.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by dklnd » Thu Dec 29, 2011 6:07 pm

Edit.

Oke I got it fixed!

dekloned.be/index.php?route=feed/latest_products_rss

It's showing the productinfo double; any ideas?

Active Member

Posts

Joined
Mon Nov 14, 2011 6:30 pm

Post by straightlight » Thu Dec 29, 2011 10:32 pm

Just by showing the RSS feeds won't really help to get the right information. The first things to know is starting from your 'got it fixed', what was the way to make that happen as a result of having double productinfo results ?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by kralizec » Fri Dec 30, 2011 7:01 pm

anyone has figure it out the problem in enabling the plugin? I'm having the same issue of Barryhung on OC 1.5.1

Newbie

Posts

Joined
Fri Dec 30, 2011 6:58 pm

Post by straightlight » Fri Dec 30, 2011 10:51 pm

What is your version of what you did in order to get this problem ?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 18 guests