Community Forums

Latest products feeds

Support for mods, payments, shipping, totals, modules, and languages in OpenCart v1.x

Latest products feeds

Postby tomtom » Mon May 09, 2011 11:30 am

Note: This is adapted from the original Module from krikey here http://www.opencart.com/index.php?route=extension/extension/info&extension_id=1540&filter_search=feed&sort=e.date_modified&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&amp;product_id=' . $product['product_id'] . '</link>' . "\n";
          $output .= '<link>' . str_replace('&', '&amp;', $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 .= '&#60;a href="' . str_replace('&', '&amp;', $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/product&amp;product_id=' . $product['product_id'])) . '">' . "\n";
              $output .= '&#60;img src="' . $this->model_tool_image->resize($product['image'], 80, 80) . '" border="0"/>&#60;/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);
   }
    }
}

?>
tomtom
 
Posts: 44
Joined: Sun May 23, 2010 12:28 pm

Re: Latest products feeds

Postby FT Industriels » Fri Sep 02, 2011 8:23 pm

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
FT Industriels
 
Posts: 3
Joined: Fri Jul 08, 2011 6:35 pm
Location: Morocco

Re: Latest products feeds

Postby tomtom » Fri Sep 02, 2011 9:43 pm

Well, I have not switched over to 1.5 yet, but if I do I will and post it here.
tomtom
 
Posts: 44
Joined: Sun May 23, 2010 12:28 pm

Re: Latest products feeds

Postby phatmaxi » Tue Nov 29, 2011 7:25 pm

working on an update
phatmaxi
 
Posts: 14
Joined: Sun Nov 27, 2011 9:49 pm

Re: Latest products feeds

Postby straightlight » Sun Dec 04, 2011 10:35 pm

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
Latest_products_RSS.zip
Compatible with v1.5.1.x
(18.56 KiB) Downloaded 99 times
Regards,
Straightlight
straightlight
 
Posts: 1930
Joined: Mon Nov 14, 2011 3:38 pm
Location: Canada, ON

Re: Latest products feeds

Postby phatmaxi » Tue Dec 06, 2011 5:29 pm

Last edited by phatmaxi on Tue Dec 06, 2011 6:22 pm, edited 1 time in total.
phatmaxi
 
Posts: 14
Joined: Sun Nov 27, 2011 9:49 pm

Re: Latest products feeds

Postby straightlight » Tue Dec 06, 2011 5:38 pm

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 ...
Regards,
Straightlight
straightlight
 
Posts: 1930
Joined: Mon Nov 14, 2011 3:38 pm
Location: Canada, ON

Re: Latest products feeds

Postby phatmaxi » Tue Dec 06, 2011 6:26 pm

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.php?route=feed/latest_products_rss



What's Missing from the original is the SEO and Specials price... didn't have time to figure it out.
Attachments
Latest_products_RSS.1.5.zip
My code for reference...
(20.1 KiB) Downloaded 108 times
Last edited by phatmaxi on Tue Dec 06, 2011 7:03 pm, edited 2 times in total.
phatmaxi
 
Posts: 14
Joined: Sun Nov 27, 2011 9:49 pm

Re: Latest products feeds

Postby straightlight » Tue Dec 06, 2011 6:29 pm

It's a bit clearer now that not only a URL has been posted. ;)
Regards,
Straightlight
straightlight
 
Posts: 1930
Joined: Mon Nov 14, 2011 3:38 pm
Location: Canada, ON

Postby phatmaxi » Tue Dec 06, 2011 6:35 pm

sorry for jacking your thread tomtom
Last edited by phatmaxi on Tue Dec 06, 2011 8:44 pm, edited 2 times in total.
phatmaxi
 
Posts: 14
Joined: Sun Nov 27, 2011 9:49 pm

Re: Latest products feeds

Postby phatmaxi » Tue Dec 06, 2011 6:36 pm

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

:) awesome
phatmaxi
 
Posts: 14
Joined: Sun Nov 27, 2011 9:49 pm

Re: Latest products feeds

Postby FTIndustriels » Sat Dec 10, 2011 8:59 pm

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
FTIndustriels
 
Posts: 7
Joined: Wed Jul 27, 2011 7:48 am
Location: Morocco

Re: Latest products feeds

Postby FTIndustriels » Wed Dec 14, 2011 2:33 pm

Any one can do that for us ?
Quincaillerie, Fourniture industrielle Maroc
Opencart 1.5.1.3 French edition.
IX web hosting
FTIndustriels
 
Posts: 7
Joined: Wed Jul 27, 2011 7:48 am
Location: Morocco

Re: Latest products feeds

Postby barryhung » Sun Dec 18, 2011 4:45 pm

I install the model successfully in 1.5.1.3 , but can't enable it always. anyone know why?
barryhung
 
Posts: 2
Joined: Sun Dec 18, 2011 4:39 pm

Re: Latest products feeds

Postby barryhung » Sun Dec 18, 2011 4:49 pm

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?
barryhung
 
Posts: 2
Joined: Sun Dec 18, 2011 4:39 pm

Re: Latest products feeds

Postby straightlight » Sun Dec 18, 2011 5:08 pm

In the setting table's value field from PHPMyAdmin, you will probably see it.
Regards,
Straightlight
straightlight
 
Posts: 1930
Joined: Mon Nov 14, 2011 3:38 pm
Location: Canada, ON

Re: Latest products feeds

Postby dklnd » Thu Dec 29, 2011 10:07 am

Edit.

Oke I got it fixed!

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

It's showing the productinfo double; any ideas?
dklnd
 
Posts: 89
Joined: Mon Nov 14, 2011 10:30 am

Re: Latest products feeds

Postby straightlight » Thu Dec 29, 2011 2: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 ?
Regards,
Straightlight
straightlight
 
Posts: 1930
Joined: Mon Nov 14, 2011 3:38 pm
Location: Canada, ON

Re: Latest products feeds

Postby kralizec » Fri Dec 30, 2011 11:01 am

anyone has figure it out the problem in enabling the plugin? I'm having the same issue of Barryhung on OC 1.5.1
kralizec
 
Posts: 7
Joined: Fri Dec 30, 2011 10:58 am

Re: Latest products feeds

Postby straightlight » Fri Dec 30, 2011 2:51 pm

What is your version of what you did in order to get this problem ?
Regards,
Straightlight
straightlight
 
Posts: 1930
Joined: Mon Nov 14, 2011 3:38 pm
Location: Canada, ON

Next

Return to Extension Support

Who is online

Users browsing this forum: fma1955 and 5 guests

Hosted by Arvixe Web Hosting