You are here:  » RSS feed of new items


RSS feed of new items

Submitted by apa on Thu, 2008-11-27 13:22 in

Hi David,

Can i make an "rss.php" file that shows maybe the 100 latest items added to the database?

Regards,
Anders

Submitted by support on Thu, 2008-11-27 13:33

Hello Anders,

Unfortunately the import process deletes all products before importing the entire feed (this is the most straight forward way to make sure the database matches the feed). It would be possible to do the last imported products; but these would always be the last 100 imported of the last feed to be imported....

You'll find the basic rss.php code on this page:

http://www.pricetapestry.com/node/1110

In that script, you'll see the following SQL code to select the products to be included in the feed:

  $sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE merchant='".database_safe($_GET["merchant"])."'";

...so to select the last 100 products, try something like:

  $sql = "SELECT * FROM `".$config_databaseTablePrefix."products` ORDER BY id DESC LIMIT 100";

Hope this helps!

Cheers,
David.

Submitted by apa on Thu, 2008-11-27 13:49

Hi David,

Thanks! Could i make it a feed of item from single specified merchant - instead of a general merchants-feed?

Kind regards,
Anders

Submitted by support on Thu, 2008-11-27 14:28

Hi Anders,

Sure - that basically just involves merging the 2 queries, giving you:

  $sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE merchant='".database_safe($_GET["merchant"])."' ORDER BY id DESC LIMIT 100";

...and would of course need to be invoked using rss.php?merchant=Some+Merchant

Cheers,
David.

Submitted by Rocket32 on Tue, 2014-08-05 03:30

Does the rss.php codes still work for the recent updates of Price Tapestry? If so, I would like to know how to produce a rss feed with the Top 100 (highest priced or top visited) products for the PT Site or for a particular merchant.

Submitted by support on Tue, 2014-08-05 08:48

Hi Rocket32,

The script from node 1110 is absolutely fine for use with the latest distributions.

For the top 100 highest priced products either by site or by merchant, look for the following code at line 11:

  $sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE merchant='".database_safe($_GET["merchant"])."'";

...and REPLACE with:

  if (isset($_GET["merchant"]))
  {
    $where = " WHERE merchant = '".database_safe($_GET["merchant"])."' ";
  }
  else
  {
    $where = "";
  }
  $sql = "SELECT *,MIN(price) AS minPrice FROM `".$config_databaseTablePrefix."products` ".$where." GROUP BY name ORDER BY minPrice DESC LIMIT 100";

Then for the top 100 highest priced for the entire site simply request:

http://www.example.com/rss.php

...or by merchant:

http://www.example.com/rss.php?merchant=Merchant+Name

Price Tapestry "out of the box" doesn't capture clicks per product, only per feed. That can be done but does involve moving to the update / insert rather than delete / insert method of importing so that a `clicks` field on pt_products is preserved between imports. It's generally OK to do for niche sites, the only downside is that it can result in a fragmented products table which can lead to a reduction in performance but if that becomes an issue it would be possible to set up and optimisation process. Let me know if you'd like to implement this, and if so for which distribution of Price Tapestry...

Cheers,
David.
--
PriceTapestry.com