Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

RSS script, only Product Title and Description Rate Topic   - - - - -

 
  • Predator
  • Junior Member
  • Members
  • Join Date: 27-Jul 07
  • 16 posts

Posted 30 July 2007 - 09:45 PM #1

Hi guys, i was messing around with some php scripts that will create an RSS feed of your Product title and Description.

First create a PHP file "rss.php" add the following code into it and put it in your root dir (or create an rss directory and put it there). The CDATA commands helps the parsing of some characters in xml format so the feed gets validated and show up correctly.

<? header('Content-type: text/xml'); ?>


<?php

$dbhost = "localhost"; // almost always localhost.

$dbname = "databasename"; // Database Name, In our case, its news

$dbuser = "username"; // Database Username

$dbpass = "password"; // Databse Password



$connect = mysql_connect("$dbhost","$dbuser","$dbpass");// Connecting to Database

mysql_select_db($dbname) or die (mysql_error()); // Selecting Database

?>

<rss version="2.0">

<channel>


<title>Your Title Here</title>
<link>Link of you page</link>
<description>Description of your store</description>

<?

$sql = "SELECT * FROM cscart_product_descriptions";

$result = mysql_query($sql);

while($row = mysql_fetch_assoc($result)){

?>
<item>
<title><?=$row['product']; ?></title>
<description><![CDATA[<?=$row['full_description']; ?>]]></description>
<link>http://www.yoursite....rget=products<![CDATA[&]]>product_id<![CDATA[=]]><?=$row['product_id']; ?></link>
</item>
<?
}
?>
</channel>
</rss>


Of course you can play with the rows and add short description instead of full. I was trying to grab data from the "cscart_products" table to list the price from the "list_price" row but i dont know how to do it. My knowledge is very limited, if someone else could make this happen it would be great!

If you like, for security reasons you can make an additional 'config.php' file to open the connection to the database and store it in a safer place than the root of your server and then insert an "include" command inside the 'rss.php' to call it.

Here in Greece RSS feeds for online stores are usefull in some ways especially in sites like the froogle but in Greek version but it's not free ;)

Feel free to make any suggestion to a n00b! :D

 
  • illusion
  • Senior Member
  • Members
  • Join Date: 17-Apr 07
  • 174 posts

Posted 03 September 2007 - 10:03 AM #2

Hi predator,

Did you have any trouble with this script? Does it render the database with to the XML? I have tried a similar script from yours, the only major difference being the CDATA thing, I think.

You can read the post here.

Please let me know if you got it to work or not ;)

Cheers!

 
  • tweaker
  • Senior Member
  • Members
  • Join Date: 03-Aug 07
  • 156 posts

Posted 03 September 2007 - 11:51 PM #3

Hey by chance can you do this to a single category?

 
  • illusion
  • Senior Member
  • Members
  • Join Date: 17-Apr 07
  • 174 posts

Posted 04 September 2007 - 07:46 AM #4

tweaker, what you'll have to to is follow one of these two scripts (the ones Predator proposed or the one I did) and add a statement to the SQL, something like

IF "category" equals "4"...

You still have to find the right SQL syntax and the right table in the database that has the categories.

 
  • tweaker
  • Senior Member
  • Members
  • Join Date: 03-Aug 07
  • 156 posts

Posted 04 September 2007 - 07:47 PM #5

I'm not all that SQL savvy. I found the $sql area but I don't know what to change. The category ID is 63.

And when I try it without modifying anything except what needed to be changed I get the following error.


XML Parsing Error: not well-formed
Location: http://users2.250hos...s/store/rss.php
Line Number 5, Column 97: <link>http://users2.250hos...ry_id=63</link>
------------------------------------------------------------------------------------------------^

Truth be told I have no idea what I'm even looking at.

 
  • coder
  • Senior Member
  • Members
  • Join Date: 19-Jun 07
  • 411 posts

Posted 05 September 2007 - 11:38 PM #6

What is the difference what we are discussing here and the RSS feed (default created) by Google for you in Google Base account.

Click the link in your Google Base account, under Your published items:

and on the page where it lists your item..... or right side you get the RSS link

>>>> Post an item *RSS*

CS-CART: version 4.9.1


 
  • tweaker
  • Senior Member
  • Members
  • Join Date: 03-Aug 07
  • 156 posts

Posted 05 September 2007 - 11:45 PM #7

For me what I want to do is help distribute amongst my clientel community this one particular category of clearance products so that people who visit these websites see products change price. It's a huge advantage for me because the majority of these people run a website using CMS.

 
  • illusion
  • Senior Member
  • Members
  • Join Date: 17-Apr 07
  • 174 posts

Posted 17 September 2007 - 12:05 PM #8

What I would like to accomplish is to get a RSS feed listing all my products OR products for a single category so that customers get updated on what is latest in our store.

It looks like it's really simple, but haven't found a solution so far.

 
  • zanimo
  • Junior Member
  • Members
  • Join Date: 04-Feb 08
  • 6 posts

Posted 09 March 2008 - 09:36 PM #9

Hi guys, i was messing around with some php scripts that will create an RSS feed of your Product title and Description.

First create a PHP file "rss.php" add the following code into it and put it in your root dir (or create an rss directory and put it there). The CDATA commands helps the parsing of some characters in xml format so the feed gets validated and show up correctly.

<? header('Content-type: text/xml'); ?>


<?php

$dbhost = "localhost"; // almost always localhost.

$dbname = "databasename"; // Database Name, In our case, its news

$dbuser = "username"; // Database Username

$dbpass = "password"; // Databse Password



$connect = mysql_connect("$dbhost","$dbuser","$dbpass");// Connecting to Database

mysql_select_db($dbname) or die (mysql_error()); // Selecting Database

?>

<rss version="2.0">

<channel>


<title>Your Title Here</title>
<link>Link of you page</link>
<description>Description of your store</description>

<?

$sql = "SELECT * FROM cscart_product_descriptions";

$result = mysql_query($sql);

while($row = mysql_fetch_assoc($result)){

?>
<item>
<title><?=$row['product']; ?></title>
<description><![CDATA[<?=$row['full_description']; ?>]]></description>
<link>http://www.yoursite.com/index.php?target=products<![CDATA[&]]>product_id<![CDATA[=]]><?=$row['product_id']; ?></link>
</item>
<?
}
?>
</channel>
</rss>


Of course you can play with the rows and add short description instead of full. I was trying to grab data from the "cscart_products" table to list the price from the "list_price" row but i dont know how to do it. My knowledge is very limited, if someone else could make this happen it would be great!

If you like, for security reasons you can make an additional 'config.php' file to open the connection to the database and store it in a safer place than the root of your server and then insert an "include" command inside the 'rss.php' to call it.

Here in Greece RSS feeds for online stores are usefull in some ways especially in sites like the froogle but in Greek version but it's not free ;)

Feel free to make any suggestion to a n00b! :D


Hello i have this error

<b>Warning</b>: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Acce...

Thanks.

 

Posted 09 March 2008 - 11:57 PM #10

zanimo check your database username and password
I've moved on from CS-Cart to WooC******** - If you need anything I can be of little help.

 
  • zanimo
  • Junior Member
  • Members
  • Join Date: 04-Feb 08
  • 6 posts

Posted 10 March 2008 - 06:38 AM #11

zanimo check your database username and password


oups... thanks it's ok now.

 
  • sonney1972
  • Junior Member
  • Members
  • Join Date: 25-Feb 08
  • 6 posts

Posted 01 September 2008 - 12:01 PM #12

Hi guys, i was messing around with some php scripts that will create an RSS feed of your Product title and Description.

First create a PHP file "rss.php" add the following code into it and put it in your root dir (or create an rss directory and put it there). The CDATA commands helps the parsing of some characters in xml format so the feed gets validated and show up correctly.

<? header('Content-type: text/xml'); ?>


<?php

$dbhost = "localhost"; // almost always localhost.

$dbname = "databasename"; // Database Name, In our case, its news

$dbuser = "username"; // Database Username

$dbpass = "password"; // Databse Password



$connect = mysql_connect("$dbhost","$dbuser","$dbpass");// Connecting to Database

mysql_select_db($dbname) or die (mysql_error()); // Selecting Database

?>

<rss version="2.0">

<channel>


<title>Your Title Here</title>
<link>Link of you page</link>
<description>Description of your store</description>

<?

$sql = "SELECT * FROM cscart_product_descriptions";

$result = mysql_query($sql);

while($row = mysql_fetch_assoc($result)){

?>
<item>
<title><?=$row['product']; ?></title>
<description><![CDATA[<?=$row['full_description']; ?>]]></description>
<link>http://www.yoursite.com/index.php?target=products<![CDATA[&]]>product_id<![CDATA[=]]><?=$row['product_id']; ?></link>
</item>
<?
}
?>
</channel>
</rss>


Of course you can play with the rows and add short description instead of full. I was trying to grab data from the "cscart_products" table to list the price from the "list_price" row but i dont know how to do it. My knowledge is very limited, if someone else could make this happen it would be great!

If you like, for security reasons you can make an additional 'config.php' file to open the connection to the database and store it in a safer place than the root of your server and then insert an "include" command inside the 'rss.php' to call it.

Here in Greece RSS feeds for online stores are usefull in some ways especially in sites like the froogle but in Greek version but it's not free ;)

Feel free to make any suggestion to a n00b! :D


Can you change the code to read the site news instead of products or catigories?

 
  • jeremyw
  • Junior Member
  • Members
  • Join Date: 05-Jun 07
  • 7 posts

Posted 02 January 2009 - 08:05 PM #13

After much experimenting and reading posts here and several other places I've come up with a way to build an RSS feed of our site's News articles. Thanks to Ryan Barr for the basic code solution!

Please note that due to my lack of knowledge with multiple sql queries, there is no ITEM DATE attached to each item as cs-cart decided to store that in a different table. Anybody know how to get that info and pull it in?

First of all, make a folder in your site root called "rss" or "feed" or whatever you want. Then place this PHP script inside named as "index.php" and edit the necessary areas (dbuser, dbpass, dbname, dbserver (localhost, perhaps) and the title, link, description and copyright. Save the file and test it.
If this works for you, please enjoy!

<?php $db = new mysqli("dbserver", "dbuser", "dbpass", "dbname"); ?>
<?php header('Content-type: text/xml'); ?>
<?php echo "<?";?>xml version="1.0" encoding="iso-8859-1"<?php echo "?>";?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Your Site Title Here</title>
<link>Your Site News Link Here</link>
<description>Your Description Here</description>
<copyright>Your Copyright Here</copyright>
<atom:link href="http://yoursite.com/rss/" rel="self" type="application/rss+xml" />

<?php
$query = 'SELECT * FROM `cscart_news_descriptions` ORDER BY `cscart_news_descriptions`.`news_id` DESC LIMIT 0,10';
$results = $db->query($query);
$number = $results->num_rows;

for ($i = 1; $i <= $number; $i++) {

$row = $results->fetch_assoc();

$title = $row['news'];
$description = $row['description'];
$link = $row['news_id'];
?>

<item>
<title><?php echo $title; ?></title>
<description><![CDATA[<?php echo $description; ?>]]></description>
<link>http://www.viewville.com/index.php?target=news#<?php echo $link; ?></link>
<guid>http://www.viewville.com/index.php?target=news#<?php echo $link; ?></guid>
</item>

<?php
}
?>

</channel>
</rss>

<?php
$db->close();
?>


 
  • clips
  • Aged Resident Loon
  • Members
  • Join Date: 14-Jan 07
  • 1650 posts

Posted 29 January 2009 - 01:04 AM #14

After much experimenting and reading posts here and several other places I've come up with a way to build an RSS feed of our site's News articles. Thanks to Ryan Barr for the basic code solution!


I have installed the feed and it works great! Thanks for the post! We were getting ready to start posting more news and use it to update folks. This is a great way to be able to do it.

Any idea what permissions I am supposed to have the file as? Right now I saved it with '644'.
Regards,
Jim

 
  • CSCartSkins
  • Senior Member
  • Members
  • Join Date: 07-Jan 09
  • 195 posts

Posted 29 January 2009 - 02:36 AM #15

Awesome work. I got it installed on one of my client's site and it works perfectly.

I did have problems getting it to work on my cscartskins site though...not sure what the problem is.

 
  • elmer328
  • Member
  • Members
  • Join Date: 12-Jan 09
  • 59 posts

Posted 09 March 2009 - 11:30 PM #16

Hey Everyone...

I'm trying to get the Products RSS feed going....

It appears to almost work - 2 products show up in the feed, but then I get the following error:

This page contains the following errors:

error on line 29 at column 43: xmlParseEntityRef: no name
Below is a rendering of the page up to the first error.

Any thoughts? Thank you!
- Jeff