Jump to content

RSS product feed


Recommended Posts

Hoi,

 

Kan iemand mij vertellen hoe ik de module RSS product feed v0.2 by PrestaShop gebruik?

Ik wil voor de site beslist.nl een lijst opgeven van de producten die op mijn site staan.

Het is mij onduidelijk hoe en waar de feed wordt gegenereerd door deze module.

 

Alvast dank,

Carel

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

Ja idd heeft al een soort rss feed ingebouwd, zo te zien moet je /modules/feeder/rss.php aanpassen. Als ik tijd over heb zal ik me er eens opstorten en hier dan plaatsen, lijkt me niet zo moeilijk, maar nu school opnieuw begonnen is is dat allemaal makkelijker gezegd dan gedaan natuurlijk...

Link to comment
Share on other sites

Heb zonet het bestandje afgewerkt en toegevoegd op beslist.be, alles is tot nu toe in orde dus zal ik even de code hier plaatsen, ik heb gewoon het bestandje rss.php aangepast dus daar plak je dan gewoon deze code in. Van modules maken ken ik niet zoveel dus misschien iemand met meer tijd en kennis kan dit misschien wat uitbreiden.

 

Opgepast: om mijn portokosten te bepalen gebruik ik het gewicht van een product, dus waarschijnlijk zal dit zeker niet bij alle shops hetzelfde zijn. Ook zijn al mijn producten voor dames bedoeld dus het is mogelijk dat daar ook een aanpassing nodig is. De code zelf is eig niet zo moeilijk dus kleine aanpassingen kunnen vlug gemaakt worden hoor!

 

Verder heb ik nog voor gezorgd dat productnamen met ampersand correct worden weergegeven, en producten in de home categorie worden ook niet weergegeven (mijn producten staan nooit ALLEEN in home)

 

Mijn prestashop versie is 1.4.0.17

 

Hopelijk zijn jullie hier nog iets mee

 

EDIT: niet vergeten om altijd een backup van het origineel te nemen!

 

<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2011 PrestaShop SA
*  @version  Release: $Revision: 1.4 $
*  @license	http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
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 => 'ASC', 1 => 'DESC');
$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', 'ASC');
$currency = new Currency((int)($cookie->id_currency));
$affiliate = (Tools::getValue('ac') ? '?ac='.(int)(Tools::getValue('ac')) : '');


// Send feed
header("Content-Type:text/xml; charset=utf-8");
echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
?>
<catalogus>
<?php
foreach ($products AS $product)
{
		if ($product['active'] == 1){
			$image = Image::getImages((int)($cookie->id_lang), $product['id_product']);
 echo "\t\t<product>\n";

			// & in titel naar & omzetten
 echo "\t\t\t<Title>".str_replace("&", "&" , $product['name'])."</Title>\n";

 echo "\t\t\t<Prijs>".html_entity_decode( Product::getPriceStatic($product['id_product']))."</Prijs>\n";

			echo  "\t\t\t<Categorie>";
			$cats = Product::getProductCategories($product['id_product']);
			foreach ($cats AS $cat)
			{
				//home category niet tonen
				if($cat != 1){
					$catnames = Category::getSimpleCategories($cookie->id_lang);
					foreach ($catnames as $catname){
						if ($catname['id_category'] == $cat)
						echo $catname['name'];
					[spam-filter]}
			echo  "</Categorie>\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<Portokosten>";
			if ($product['weight'] == 1){
				 echo "2";
			}else{
				echo "6";
			}
			echo "</Portokosten>\n";

			echo "\t\t\t<Levertijd>";
			if ($product['quantity']== 0){
				echo "Niet op voorraad";
			}else{
				echo "1-2 werkdagen";
			}
			echo "</Levertijd>\n";

			echo "\t\t\t<Winkelproductcode>";
			echo $product['id_product'];
			echo "</Winkelproductcode>\n";
 echo "\t\t\t<Deeplink>".htmlspecialchars($link->getproductLink($product['id_product'], $product['link_rewrite'], Category::getLinkRewrite((int)($product['id_category_default']), $cookie->id_lang))).$affiliate."</Deeplink>\n";

			echo "\t\t\t<Geslacht>";
			echo "Dames";
			echo "</Geslacht>\n";



			echo "\t\t</product>\n";


			}
	}


?>
</catalogus>

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...
  • 3 weeks later...

Ik gebruik 1.3 en wil de title en prijs los van elkaar hebben

Hoe moet ik dit doen

de code is nu:

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";

Link to comment
Share on other sites

Ik gebruik 1.3.

als ik de code gebruik van denis dan krijg ik de <Categorie> niet.

De pagina is dan blank.

Hoe kan ik de <Categorie> toch laten weergeven?

 

Dit is mijn code:

<?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

  • 3 weeks later...

Beste Denis,

 

Heb net je code geprobeerd op beslist, krijg alleen een hele vage prijs error..

Ik heb prijzen met een punt en veel te veel decimalen achter de "punt" komma.

aangezien ik absoluut geen programmeur ben..

 

Weet iemand hier hoe je de prijs vb. 169.00023 omzet naar een prijs als 169,00 ??

 

Als iemand mij kan helpen zou 2012 voor mij heel goed beginnen :)

Link to comment
Share on other sites

  • 7 months later...

Hoi,

 

Ik heb het zelfde probleem.

 

Welke code zet ik waar nee voor de beslist.nl feed?

 

Welke URL geef ik in bij beslist.nl?

 

Is er al iemand die de complete oplossing werkend heeft gekregen.

 

Alvast bedankt voor alle mogelijke hulp.

Link to comment
Share on other sites

  • 4 weeks later...
  • 1 year later...

Hello all!

 

Oude post, maar toch ff hier omdat ik bovenstaande code heb gebruikt..

Nu loop ik tegen de nieuwe sub-directory structuur van Prestashop aan.. 

img 100 staat nu in : img/p/1/0/0 en Beslist.nl krijgt hierdoor niet mn plaatjes mee!  

 

Hoe moet ik de code aanpassen om dit op te lossen?

 

De rest werkt volgens mij nog wel..

 

Merci!

 

Hello all!
 
Old post, but ff here because I used the above code ..
Now I stumble upon the new sub-directory structure of Prestashop ..
img 100 is now in: img/p/1/0/0 and Beslist.nl will not get mn pictures with you!
 
How do I modify the code to solve this?
 
The rest work in my still ..
 
Merci!
Edited by wiebrande (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...
×
×
  • Create New...