Flux RSS version 5.2

14 posts in this topic

Posted · Report post

Bonjour

Quelqu'un sait-il comment modifier la requête pour n'afficher que les produits nouveaux ET/OU les produits en promo ?

Ci-dessous, le code du fichier rss.php

Merci pour votre aide

<?php

include("configuration.inc.php");

Header("content-type: application/xml");

// En-tête

echo "<"."?xml version=\"1.0\" encoding=\"ISO-8859-1\"?".">

<rss version=\"2.0\">

<channel>

<title>Flux rss du site $site</title>

<link>$wwwroot</link>

<description>Voici notre flux rss en cours</description>

";

// R&eacute;cup&eacute;ration et affichage des donn&eacute;es

$sql = "SELECT id, prix, nom_".$_SESSION['langue']." as nom, date_maj, description_".$_SESSION['langue']." as description, promotion FROM peel_produits INNER JOIN peel_sites_pivots ON (produit_id = id) WHERE etat =1' AND site_id = '".intval($_SESSION['ecom]['id'])."'";

$result=mysql_query($sql) or DIE('Une erreur de connexion &agrave; la base s est produite ' . __LINE__ . '.<p>' . MYSQL_ERROR());

while($prod=mysql_fetch_array($result))

{

$prix = $prod['prix'] * (1-$prod['promotion']/100);

$id_rss = $prod['id'];

$nom_rss = $prod['nom'];

$date_rss = $prod['date_maj'];

$desc_rss = $prod['description'];

$promotion_rss = $prod['promotion'];

$date = strtotime($date_rss);

echo "<item>

<title>".$nom_rss." : $prix EUR</title>";

echo ($promotion > 0) ? "<promotion>- ".$promotion_rss." %</promotion>" : "";

echo "<guid>".$wwwroot."/achat/produit_details.php?id=".$id_rss."</guid>

<pubDate>".gmdate('D, d M Y H:i:s',$date)." GMT</pubDate>

<description>".$desc_rss."</description>

</item>

";

}

// Fin d'affichage

echo "</channel>

</rss>

";

?>

Share this post


: post
Share on other sites

Posted · Report post

 

Share this post


: post
Share on other sites

Posted · Report post

Merci Eric, cela fonctionne.

Share this post


: post
Share on other sites

Posted · Report post

bonsoir !

le réponse a disparu ? ca m'intéresses !

merci.

Share this post


: post
Share on other sites

Posted · Report post

voila ce qu'Eric m'avait conseillé :

WHERE etat ='1' AND on_promo='1' OR on_new='1' AND site_id = '".intval($_SESSION['ecom']['id'])."'";

Share this post


: post
Share on other sites

Posted · Report post

Bonjour,

WHERE etat ='1' AND on_promo='1' OR on_new='1' AND site_id = '".intval($_SESSION['ecom']['id'])."'";

fonctionne?

J'écrirais plutôt :

WHERE etat ='1' AND (on_promo='1' OR on_new='1') AND site_id = '".intval($_SESSION['ecom']['id'])."'";

pour être certain des priorités que SQL donnera aux clauses OR / AND

Share this post


: post
Share on other sites

Posted · Report post

bah je vais rectifier, si cela permet de faire encore mieux ;-)

Merci Jean-Hervé.

Share this post


: post
Share on other sites

Posted · Report post

Bonjour,

merci pour vos réponses !

Chez moi cela ne fonctionne pas.

Je voudrai qu'il ne s'affiche que les nouveaux produits. Or ici il s'affiche les produits dont la fiche produit a été modifiée ainsi que les promotions.

Voici mon code :

<?php


include("configuration.inc.php");


Header("content-type: application/xml");


// En-tête


echo "<"."?xml version=\"1.0\" encoding=\"ISO-8859-1\"?".">

<rss version=\"2.0\">

<channel>

<title>Flux rss du site $site</title>

<link>$wwwroot</link>

<description>Voici notre flux rss en cours</description>

";


// R&eacute;cup&eacute;ration et affichage des donn&eacute;es

$sql = "SELECT id, prix, nom_".$_SESSION['langue']." as nom, date_maj, description_".$_SESSION['langue']." as description, promotion FROM peel_produits INNER JOIN peel_sites_pivots ON (produit_id = id) WHERE etat ='1' AND (on_promo='1' OR on_new='1') AND site_id = '".intval($_SESSION['ecom']['id'])."'"; 

$result=mysql_query($sql) or DIE('Une erreur de connexion &agrave; la base s est produite ' . __LINE__ . '.<p>' . MYSQL_ERROR());

while($prod=mysql_fetch_array($result))

{


$prix = $prod['prix'] * (1-$prod['promotion']/100);

$id_rss = $prod['id'];

$nom_rss = $prod['nom'];

$date_rss = $prod['date_maj'];

$desc_rss = $prod['description'];

$promotion_rss = $prod['promotion'];

$date = strtotime($date_rss);

echo "<item>

<title>".$nom_rss." : $prix EUR</title>";

echo ($promotion > 0) ? "<promotion>- ".$promotion_rss." %</promotion>" : "";

echo "<guid>".$wwwroot."/achat/produit_details.php?id=".$id_rss."</guid>

<pubDate>".gmdate('D, d M Y H:i:s',$date)." GMT</pubDate>

<description>".$desc_rss."</description>

</item>

";

}

// Fin d'affichage

echo "</channel>

</rss>

";

?>

Share this post


: post
Share on other sites

Posted · Report post

Bonjour Jeffoul

Pour n'afficher que les nouveaux produits, faire :

WHERE etat ='1' AND on_new='1' AND site_id = '".intval($_SESSION['ecom']['id'])."'";

Share this post


: post
Share on other sites

Posted · Report post

Bonjour,

ca ne fonctionne toujours pas ! ;)

Share this post


: post
Share on other sites

Posted · Report post

mais, tu as bien coché la case "nouveauté" dans la fiche produit ? parce que le code a l'air bon.

Share this post


: post
Share on other sites

Posted · Report post

à priori entre ta page

http://shop.brestunt.com/rss.php et http://shop.brestunt.com/achat/nouveautes.php

on a bien la même chose (mais pas dans le même ordre - suffit de mettre un tri dans la requête).

Mais c'est dans ta page http://feeds.feedburner.com/shopbrestunt que ça bloque.

N'es tu pas limité en affichage avec cette application ?

As tu bien recopié le bon code ?

Share this post


: post
Share on other sites

Posted · Report post

Autant pour moi, ça fonctionne, seulement les derniers produits ajoutés se trouve au bas de la page. Comment faire pour inverser cet ordre ?

Share this post


: post
Share on other sites

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

Twitter Advisto ecommerce

Facebook PEEL Shopping