Jump to content

Get all products in RSS


Recommended Posts

  • 3 weeks later...

I've been working on this recently. I also wanted to change the RSS feed to show newly added products and not featured products.

*Make sure your RSS product feeder is enabled in your shop admin.*
*Make a backup of your files before making changes.*


There are two PHP files to edit:

1. /modules/feeder/rss.php

Change Lines 7 and 8:

$orderByValues = array(0 => 'name', 1 => 'price', 2 => 'date_add', 3 => 'date_upd', 4 => 'position');
$orderWayValues = array(0 => 'ASC', 1 => 'DESC');



to read:

$orderByValues = array(0 => 'date_add', 1 => 'price', 2 => 'name', 3 => 'date_upd', 4 => 'position');
$orderWayValues = array(0 => 'DESC', 1 => 'ASC');



Change Line 16:

$products = Product::getProducts(intval($cookie->id_lang), 0, ($number > 10 ? 10 : $number), $orderBy, $orderWay, $id_category, true);



to read:

$products = Product::getNewProducts(intval($cookie->id_lang), 0, 10, false, $orderBy, $orderWay);



Now browse to:

[your shop url]/modules/feeder/rss.php



You should now see an RSS list of the latest ten products you added, with the very latest at the top.

2. /modules/feeder/feeder.php

Change Lines 58/59/60:

$smarty->assign(array(
           'feedUrl' => 'http://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'modules/'.$this->name.'/rss.php?id_category='.$id_category.'&orderby='.$orderBy.'&orderway='.$orderWay,
       ));



to read:

$smarty->assign(array(
           'feedUrl' => 'http://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'modules/'.$this->name.'/rss.php'));



This will change the standard URL so that the RSS feed icon in the browser points to the improved RSS feed.

HTH

P.S. Sorry, I'm new to this forum - is there an FAQ section (or similar) I can post this in to help more people find it?

  • Like 1
Link to comment
Share on other sites

Thanks a lot! It's working, however it doesn't exactly show the latest 10 products, I think it might have something to do with the time settings, not sure if its PS related or server related. However, I'm glad it works coz it now shows 10 products not on the home featured like the original feeder module. So thank you very much!

Link to comment
Share on other sites

Thanks peanut. :D
I wasn't sure if the products were exactly the last ten added as the shop I was working on wasn't my own. The code uses a standard Prestashop function - GetNewProducts, which I had assumed would 'do what it said on the tin'. I suppose it is possible that there are some features/bugs in that function that exclude certain products, I'm not sure. Perhaps the admins can shed further light on this.

Link to comment
Share on other sites

Hi

I made a small change to your code in rss.php, added what Rocky posted in this forum post:
http://www.prestashop.com/forums/viewthread/57484/#271103 . Changed his code from 1 to 0. Now it displays the 10 latest products!!

$products = Product::getNewProducts(intval($cookie->id_lang), 0, 10, false, 'date_add', 'DESC');





Thanks! Hope it works for everyone else as well.

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
  • 5 weeks later...
  • 1 month later...
  • 1 month later...
  • 1 month later...
  • 1 month later...

Thanks, this work perfectly.

 

ps: I get the code to render latest product by changing line 16 to this:

 


$products = Product::getNewProducts(intval($cookie->id_lang), 0, 20, false, 'date_add', 'DESC');

Link to comment
Share on other sites

  • 3 months later...
  • 2 weeks later...
  • 3 weeks later...

Hi d3mon

 

Thank you a lot it's working great :)

 

Please just tell me, I never understood the RSS module, it's necessary to install that module?

I try to put the url my.domaincom/modules/feeder/rss.php but it says that it's my domain and it doesn't work...

 

I don't understand this module but the RSS feed icon in the browser points to the improved RSS feed and it's working great.

 

Thanks

Link to comment
Share on other sites

  • 3 months later...

Hello

 

Sorry to dig the old post,

 

I'm using PS1.4.7.0 at the moment, but this "RSS products feed v0.2 by PrestaShop" doesn't update any new feature products or new products to me. I wonder if the modify code abouve is still work on PS1.4.7.0...

 

I will later when I get to home...

 

btw, I wish that prestashop will up date this module in the newer version ?

I think it will be very useful to update the lasted products insead of showing only feature products.

Link to comment
Share on other sites

  • 2 months later...

to show all your products

$products = Product::getNewProducts(intval($cookie->id_lang), 0, 20, false, 'date_add', 'DESC');

 

just change 20 to your total products amount, example 100

 

Hi Man, sincerely it doesn't work....i'd like to put every products i have in my shop but also putting 100 and not 20 the feed RSS contains only the last 10 products i've added!

Any ideas on how to fix it?

  • Like 1
Link to comment
Share on other sites

  • 1 year later...
  • 5 years later...

Hello!

In the version 1.7.5 the module is ps_feeder. And the file to be concerned with is ps_feeder > controllers > front > rss.php.  

Also I had to modify the url from back office by going to Configure > Shop Parameters > Traffic & SEO . From there I modified friendly url for this module page refered by '

 

module-ps_feeder-rss'.  Then things worked for me.  

Hope this helps...

  • Thanks 1
Link to comment
Share on other sites

24 minutes ago, TShah said:

Hello!

In the version 1.7.5 the module is ps_feeder. And the file to be concerned with is ps_feeder > controllers > front > rss.php.  

Also I had to modify the url from back office by going to Configure > Shop Parameters > Traffic & SEO . From there I modified friendly url for this module page refered by '

 

module-ps_feeder-rss'.  Then things worked for me.  

Hope this helps...

Thanks for the steps to the file.

Do you have idea how to configure to show the last 10/20 products? 

I need something like this which worked fine https://example.com/module-ps_feeder-rss?id_category=12&orderby=date_add&orderway=desc

Link to comment
Share on other sites

Hello!

I modified for category id and posting the whole function here.  I have changed meta tags and number of products to 20.  And url would look something like - https://site-url/feed?id_category=16

    private function getSmartyVariables()
    {
        $id_category = (int)Tools::getValue('id_category');
        $id_category = $id_category ? $id_category : Configuration::get('PS_HOME_CATEGORY');
        
        // get categroy name 
        $category = new Category ($id_category,Context::getContext()->language->id);
        $catName = $category->name;
        
        if($catName !== "Home") {
            $title = "Buy Designer Luxury " . $catName ." CATEGORY META TITLE";
            $metas['description'] = "Buy " . $catName ." CATEGORY META DESC";
            $generator = "Designer " . $catName ." @ SITE NAME";
            
            $filename = "PATH TO CATEGORY IMAGE" .$id_category . ".jpg";
            
            if(file_exists($filename)){
                $logo = $filename;                
            }
            else {
                $logo = $this->context->link->getMediaLink(_PS_IMG_ . Configuration::get('PS_LOGO'));    
            }

        }
        else {
            // it is default home category
            $title = "DEFAULT HOME CATEGORY META TITLE";
            $metas['description'] = "DEFAULT META DESC";
            $generator = "DEFAULT GENERATOR";
            $logo = $this->context->link->getMediaLink(_PS_IMG_ . Configuration::get('PS_LOGO'));
        }
        

	// number of products increased to 20

        $number = (int)Tools::getValue('n', 20);
        //$number = $number > 10 ? 10 : $number;
        
        $number = $number > 20 ? 20 : $number;

        $orderBy = Tools::getProductsOrder('by', Tools::getValue('orderby'));
        $orderWay = Tools::getProductsOrder('way', Tools::getValue('orderway'));

        $products = $this->getProducts($id_category, $number, $orderBy, $orderWay);

        return array(
            'products' => $products,
            'currency' => new Currency((int)$this->context->currency->id),
            'affiliate' => (Tools::getValue('ac') ? '?ac=' . (int)Tools::getValue('ac') : ''),
            //'metas' => Meta::getMetaByPage('index', (int)$this->context->language->id),
            'metas' => $metas,
            'shop_uri' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__,
            //'shop_name' => Configuration::get('PS_SHOP_NAME'),
            'shop_name' => $title,
            'shop_email' => Configuration::get('PS_SHOP_EMAIL'),
            'language_iso' => $this->context->language->iso_code,
            //'logo' => $this->context->link->getMediaLink(_PS_IMG_ . Configuration::get('PS_LOGO')),
            'logo' => $logo,
            'generator'=>$generator,
        );
    }

 

 

Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...