Jump to content

RSS product feed


Recommended Posts

Hi,

 

I use version 1.3.6.0

 

How do i get the product category and manufacturer in to this RSS Feed?

 

<?php
include(dirname(__FILE__).'/../../config/config.inc.php');
require_once(dirname(__FILE__).'/../../init.php');
// Get data
$number = ((int)(Tools::getValue('n')) ? (int)(Tools::getValue('n')) : 10);
$orderByValues = array(0 => 'name', 1 => 'price', 2 => 'date_add', 3 => 'date_upd', 4 => 'position', 5 => 'manufacturer_name', 6 => 'quantity');
$orderWayValues = array(0 => 'DESC', 1 => 'ASC');
$orderBy = Tools::strtolower(Tools::getValue('orderby', $orderByValues[(int)(Configuration::get('PS_PRODUCTS_ORDER_BY'))]));
$orderWay = Tools::strtoupper(Tools::getValue('orderway', $orderWayValues[(int)(Configuration::get('PS_PRODUCTS_ORDER_WAY'))]));
if (!in_array($orderBy, $orderByValues))
$orderBy = $orderByValues[0];
if (!in_array($orderWay, $orderWayValues))
$orderWay = $orderWayValues[0];
$id_category = ((int)(Tools::getValue('id_category')) ? (int)(Tools::getValue('id_category')) : 1);
$products = Product::getProducts((int)($cookie->id_lang), 0, NULL, 'id_product', 'DESC');
//$currency = new Currency((int)($cookie->id_currency));
$affiliate = (Tools::getValue('ac') ? '?ac='.intval(Tools::getValue('ac')) : '');
//$prijs = (Tools::displayPrice('id_product'))Product::getPriceStatic('id_product'));
// Send feed
header("Content-Type:text/xml; charset=utf-8");
echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
?>
<rss version="2.0">
<channel>
 <title><![CDATA[<?php echo Configuration::get('PS_SHOP_NAME') ?>]]></title>
 <link><?php echo _PS_BASE_URL_.__PS_BASE_URI__; ?></link>
 <mail><?php echo Configuration::get('PS_SHOP_EMAIL') ?></mail>
 <generator>PrestaShop</generator>
 <language><?php echo Language::getIsoById(intval($cookie->id_lang)); ?></language>
 <image>
  <title><![CDATA[<?php echo Configuration::get('PS_SHOP_NAME') ?>]]></title>
  <url><?php echo _PS_BASE_URL_.__PS_BASE_URI__.'img/logo.jpg'; ?></url>
  <link><?php echo _PS_BASE_URL_.__PS_BASE_URI__; ?></link>
 </image>
<?php
foreach ($products AS $product)
{
 $image = Image::getImages(intval($cookie->id_lang), $product['id_product']);
 echo "\t\t<item>\n";
 echo "\t\t\t<title><![CDATA[".$product['name']./*" - ".html_entity_decode(Tools::displayPrice(Product::getPriceStatic($product['id_product']), $currency), ENT_COMPAT, 'UTF-8').*/" ]]></title>\n";
 echo "\t\t\t<Prijs><![CDATA[".html_entity_decode(Tools::displayPrice(Product::getPriceStatic($product['id_product']), $currency), ENT_COMPAT, 'UTF-8')."]]></Prijs>\n";

 echo "\t\t\t<description>";
 $cdata = true;
 if (is_array($image) AND sizeof($image))
 {
  echo "<![CDATA[<img src='"._PS_BASE_URL_.__PS_BASE_URI__."img/p/".$image[0]['id_product']."-".$image[0]['id_image']."-home.jpg' title='".str_replace('&', '', $product['name'])."' alt='thumb' />";
  $cdata = false;
 }
 if ($cdata)
  echo "<![CDATA[";
 echo $product['description_short']."]]></description>\n";
 echo "\t\t\t<Image-locatie>";
 $cdata = true;
 if (is_array($image) AND sizeof($image))
 {
  echo _PS_BASE_URL_.__PS_BASE_URI__."img/p/".$image[0]['id_product']."-".$image[0]['id_image']."-large.jpg";
  $cdata = false;
 }
 echo "</Image-locatie>\n";

echo "\t\t\t<Winkelproductcode>";
														echo $product['id_product'];
														echo "</Winkelproductcode>\n";
echo "\t\t\t<Portokosten>";
														if ($product['weight'] == 1){
																			 echo "6.50";
														}else{
																		echo "0.00";
														}
														echo "</Portokosten>\n";
echo "\t\t\t<Levertijd>";
														if ($product['quantity']== 0){
																		echo "Niet op voorraad";
														}else{
																		echo "1 werkdag";
														}
														echo "</Levertijd>\n";
echo "\t\t\t<Geslacht>";
														echo "Dames";
														echo "</Geslacht>\n";

 echo "\t\t\t<link><![CDATA[".htmlspecialchars($link->getproductLink($product['id_product'], $product['link_rewrite'], Category::getLinkRewrite(intval($product['id_category_default']), $cookie->id_lang))).$affiliate."]]></link>\n";
 echo "\t\t</item>\n";
}
?>
</channel>
</rss>

Link to comment
Share on other sites

  • 1 month 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...