Aide - Recherche - Membres - Calendrier
Version complète : [résolu] affichage des nouveaux produits
Forum osCommerce-fr > Les Bases d'OsCommerce MS2 > Fonctionnement
fablog
Salut,

J'ai remarqué qu'OScommerce n'affiche pas que les nouveaux produits du mois dans la box des nouveautes. Y a t'il une config ou une modif a faire pour regler cela?

merci par avance

Fab
isnogood


Vas dans catalog/includes/modules/new_products.php.

L'ordre SQL affiche les x derniers produits triés par ordre d'ajout.

CODE
where products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);



Le x équivaut à MAX_DISPLAY_NEW_PRODUCTS paramétrables dasn l'admin.
fablog
Si je comprends bien mon cher isnogood, on ne peut obliger oscommerce a n'Afficher que les nouveautes du mois!! Il affiche les derniers produits sans tenir compte de la date. c'Est bien cela?
Si oui, ce n'est pas logigue avec l'affichage qui est "les nouveautes du mois de juin" par ex. N'y a t'il pas une modif possible pour changer cela?

Merci

Fabien
JeanLuc
Pour faire en sorte que cela n'affiche que les produits ajoutés durant le mois courant , modifie ainsi les deux requêtes au début du fichier (les "..." ne sont pas à mettre... wink.gif ):
CODE
... where ... p.products_status = '1' and month(p.products_date_added) = month(now()) and year(p.products_date_added) = year(now()) order by p.products_date_added DESC limit " . MAX_DISPLAY_NEW_PRODUCTS");


Bon code... wink.gif
fablog
Merci Jean luc pour ton aide, malheureusement mes competences techniques etant ce quelles sont je n'ai pas reussi a faire la modif.

Peux tu me dire precisement quoi changer a partir de mon code ci dessous:
CODE

<?php
/*
 $Id: new_products.php,v 1.34 2003/06/09 22:49:58 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/
?>
<!-- new_products //-->
<?php
 $info_box_contents = array();
 $info_box_contents[] = array('text' => sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')));

 new contentBoxHeading($info_box_contents);

 if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
   $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
 } else {
   $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
 }

 $row = 0;
 $col = 0;
 $info_box_contents = array();
 while ($new_products = tep_db_fetch_array($new_products_query)) {
   $new_products['products_name'] = tep_get_products_name($new_products['products_id']);
   $info_box_contents[$row][$col] = array('align' => 'center',
                                          'params' => 'class="smallText" width="33%" valign="top"',
                                          'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a><br>' . $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])));

   $col ++;
   if ($col > 2) {
     $col = 0;
     $row ++;
   }
 }

 new contentBox($info_box_contents);
?>
<!-- new_products_eof //-->


Merci

Fab
JeanLuc
Remplace ça:
CODE
if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
  $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
} else {
  $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
}
par ça:
CODE
if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
  $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' and month(p.products_date_added) = month(now()) and year(p.products_date_added) = year(now()) order by p.products_date_added DESC limit " . MAX_DISPLAY_NEW_PRODUCTS");
} else {
  $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1'  and month(p.products_date_added) = month(now()) and year(p.products_date_added) = year(now()) order by p.products_date_added DESC limit " . MAX_DISPLAY_NEW_PRODUCTS");
}


Bon code... wink.gif
fablog
ça ne fonctionne pas, j'ai le message d'erreur suivant sad.gif
QUOTE

Parse error: parse error, unexpected '"' in c:\easyphp\www\catalog\includes\modules\new_products.php on line 21


Je te redonne le code en entier avec ta modif

CODE

<?php
/*
 $Id: new_products.php,v 1.34 2003/06/09 22:49:58 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/
?>
<!-- new_products //-->
<?php
 $info_box_contents = array();
 $info_box_contents[] = array('text' => sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')));

 new contentBoxHeading($info_box_contents);

 if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
 $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' and month(p.products_date_added) = month(now()) and year(p.products_date_added) = year(now()) order by p.products_date_added DESC limit " . MAX_DISPLAY_NEW_PRODUCTS");
} else {
 $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1'  and month(p.products_date_added) = month(now()) and year(p.products_date_added) = year(now()) order by p.products_date_added DESC limit " . MAX_DISPLAY_NEW_PRODUCTS");
}

 $row = 0;
 $col = 0;
 $info_box_contents = array();
 while ($new_products = tep_db_fetch_array($new_products_query)) {
   $new_products['products_name'] = tep_get_products_name($new_products['products_id']);
   $info_box_contents[$row][$col] = array('align' => 'center',
                                          'params' => 'class="smallText" width="33%" valign="top"',
                                          'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a><br>' . $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])));

   $col ++;
   if ($col > 2) {
     $col = 0;
     $row ++;
   }
 }

 new contentBox($info_box_contents);
?>
<!-- new_products_eof //-->


fab
fissiaux


Sur les 2 select , tu as un double guillemet en trop à la fin.

CODE
MAX_DISPLAY_NEW_PRODUCTS");


A remplacer par

CODE
MAX_DISPLAY_NEW_PRODUCTS);


Sur les 2 SELECT !!!
fablog
Excellent, beau travail d'equipe les gars.

En passant, si je voulais afficher un message du style "pas de nouveau produit ce mois-ci" dans le cas ou aucun produit n'aurait ete ajoute dans le catalogue au cours du mois, comment coderiez-vous ça?

Merci et encore felicitation

Fab
fissiaux


Juste avant le while :

CODE
       $count=tep_db_num_rows($new_products_query);
       if ($count=0) {
            $info_box_contents[] = array('align' => 'center',
                                         'text' => 'RIEN A AFFICHER');
       }



Pour faire bien, il faudrait associer un fichier langue et afficher le message dans la langue en cours, mais bon.......
fablog
Effectivement ça serait la meilleure solution pour moi car mon site est en français et en anglais.

Tu sais faire ça fissiaux?
fissiaux

Oui biggrin.gif

J'aurais préféré que tu le fasses tout seul :

CODE
      $count=tep_db_num_rows($new_products_query);
      if ($count=0) {
           $info_box_contents[] = array('align' => 'center',
                                        'text' => RIEN_A_AFFICHER);
      }


Attention, j'ai enlevé les quotes autour de la variable puis dans catalog/includes/languages/french.php

CODE
define('RIEN_A_AFFICHER', 'blabla français');


Idem dans english.php avec blabla english
fablog
merci bcp parce que j'aurai ete incapable de le faire tout seul, je sais pas developper, je ne suis qu'un nouveau chef d'entreprise rolleyes.gif

J'essaye la modif tout de suite

Fab

fablog
Mince, ça ne fonctionne pas, meme pas de message d'erreur. Voici mon code avec la modif, qu'en penses tu fissiaux?
CODE

<?php
/*
 $Id: new_products.php,v 1.34 2003/06/09 22:49:58 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/
?>
<!-- new_products //-->
<?php
 $info_box_contents = array();
 $info_box_contents[] = array('text' => sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')));

 new contentBoxHeading($info_box_contents);

 if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
 $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' and month(p.products_date_added) = month(now()) and year(p.products_date_added) = year(now()) order by p.products_date_added DESC limit " . MAX_DISPLAY_NEW_PRODUCTS);
} else {
 $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1'  and month(p.products_date_added) = month(now()) and year(p.products_date_added) = year(now()) order by p.products_date_added DESC limit " . MAX_DISPLAY_NEW_PRODUCTS);
}

 $row = 0;
 $col = 0;
 $info_box_contents = array();
     $count=tep_db_num_rows($new_products_query);
     if ($count=0) {
          $info_box_contents[] = array('align' => 'center',
                                       'text' => RIEN_A_AFFICHER);
     }  
 while ($new_products = tep_db_fetch_array($new_products_query)) {
   $new_products['products_name'] = tep_get_products_name($new_products['products_id']);
   $info_box_contents[$row][$col] = array('align' => 'center',
                                          'params' => 'class="smallText" width="33%" valign="top"',
                                          'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a><br>' . $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])));

   $col ++;
   if ($col > 2) {
     $col = 0;
     $row ++;
   }
 }

 new contentBox($info_box_contents);
?>
<!-- new_products_eof //-->
isnogood
Déjà il faudrait savoir si le problème vient du code fourni par fissiaux ou de la variable qu'il n'arrive pa à trouver.

Donc change :

CODE
         $info_box_contents[] = array('align' => 'center',
                                      'text' => RIEN_A_AFFICHER);


par


CODE
         $info_box_contents[] = array('align' => 'center',
                                      'text' => 'rien');


Si tu as l'affichage de "rien", c'est que c'est un problème avec la variable RIEN_A_AFFICHER

Si tu n'as pas l'affichage de "rien', c'est un problème dans la condition if
fablog
le pb doit venir alors de if puisque quoi que je fasse rien ne s'affiche. Dans ce cas qu'est ce que je dois faire stp?

Merci smile.gif

Fab
fissiaux

Trop nul, fissiaux :

Rempalce

CODE
if ($count=0) {



par

CODE
if ($count==0) {


blush.gif blush.gif blush.gif blush.gif blush.gif blush.gif blush.gif blush.gif blush.gif blush.gif blush.gif blush.gif blush.gif blush.gif
fablog
Excellent les gars, ça fonctionne, merci bcp. L'union fait la force wink.gif

Bonjour du Québec

Fab
isnogood
Il ne te reste plus qu'à indiquer [résolu] dans le titre de ce sujet.
fablog
ouai j'avais oublie.
Ceci est une version "bas débit" de notre forum. Pour voir la version complète avec plus d'informations, la mise en page et les images, veuillez cliquer ici.
Invision Power Board © 2001-2013 Invision Power Services, Inc.