Version imprimable du sujet

Cliquez ici pour voir ce sujet dans son format original

Forum osCommerce-fr _ Contributions _ [RESOLU] Contribution Control New Products - Aide installation

Écrit par : croco 1 Apr 2012, 22:57

Bonjour,

Je souhaiterais installer la contribution ci-dessous:

http://www.oscommerce.com/community/contributions,3030

Elle permet, comme son nom l'indique, de controler la boxe nouveaux produits qui se situe en page d'acceuil des sites Osc.

L'installation est relativement simple mais il y a quelques points qui ne sont pas clairs et j'aurais besoin de quelques éclaircissements.

Dans le package on peut trouver plusieurs fichiers qui sont semble t-il pour ceux n'ayant jamais fais de modifications sur leur site Osc ce qui n'est pas mon cas.

J'en suis donc venu à la conclusion qu'il fallait que je fasse les modifications à la main dans chaque fichiers seulement je trouve que le readme n'est pas clair.

Il y a un fichier .sql il faut donc l'éxecuter via phpmyadmin mais dans le readme l'auteur dis de sauter cette étape si j'ai bien compris ???

Citation
SKIP! Step 1 if you use the Contol_New_Products-sql.sql Then you can define EXPIRE_NEW_PRODUCTS in
your admin shop in configuration/Control New Products [New products in..]


De plus ensuite il semble expliquer encore une nouvelle méthode d'installation à la fin du readme ????

Bref je suis un perdu et je ne sais pas si il faut que je fasse la requête SQL ou non avec le fichier .sql ???


Si quelqu'un pouvait m'éclaircir les idées et me dire quelles sont les parties du readme qu'il faut que je fasse ou non.

Je vous copie colle le readme ci-dessous:

Merci à tous smile.gif

Code
Thanks to zipper for the sql code that made life better and making a forum suggestion into a
contribution! This upgrade is based on his SQL code for calculating a cutoff date, but this
contribution update uses the original new-products.php and completes the other half of the project,
which is controlling what is shown in the New Products info box and the new products cutoff date
when someone clicks on the new products info box.

Also, there should not be any changes here that will not be compaitble with any other modifications
you may have made to these files, since I am using the original osCommerce files, and have only made
minor changes, maintaining the integrety of the original coding.

After doing the modifications listed below, set EXPIRE_NEW_PRODUCTS to how many days you would like
to keep your "new items" on the new item list. If you have no new items to list during the period
you specify, the new items bars will not show, and the new items info box will not display.

PLEASE BACK UP YOUR FILES BEFORE MAKING ANY CHANGES!

I have included the updated catalog/includes/modules/new_products.php and catalog/products_new.php
for those that have NOT modified either file, or wish to use a file-compare utility such as
Beyond Compare to make changes. If you copy these files, don't forget to do Manual Installation,
step 1, changes to catalog/includes/application_top.php.


SKIP! Step 1 if you use the Contol_New_Products-sql.sql Then you can define EXPIRE_NEW_PRODUCTS in
your admin shop in configuration/Control New Products [New products in..]

Manual installation:

####################################################
#Step 1: In catalog/includes/application_top.php   #
####################################################

add this:

// how long before new products expire days
  define('EXPIRE_NEW_PRODUCTS', '60');

just before:

// initialize the message stack for output messages
  require(DIR_WS_CLASSES . 'message_stack.php');
  $messageStack = new messageStack;

############################################
#Step 2: catalog/products_new.php          #
############################################

about line 53, look for:

<?php
  $products_new_array = array();

  $products_new_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC, pd.products_name";

relpace the entire section with:

<!-- New Product Expire //-->
<?php

$days = EXPIRE_NEW_PRODUCTS;
  $products_new_array = array();
  
  $products_new_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_date_available, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_date_added > SUBDATE( now(  ) ,  INTERVAL " . $days . "  DAY  ) and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC, pd.products_name";
?>
<!-- New Product Expire_eof //-->
<?php  

##########################################################
#Step 3: catalog/includes/modules/new_products.php #
##########################################################

***1. approx line 13 look for:****

<!-- 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);
  }

***Replace the *entire* section with: ****

<!-- new_products //-->
<!-- New Product Expire //-->
<?php
$days = EXPIRE_NEW_PRODUCTS;

  if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
    $check_products_query = tep_db_query("select count(products_id) as count from " . TABLE_PRODUCTS . " where products_status = '1' and products_date_added > SUBDATE( now(  ) ,  INTERVAL " . $days . "  DAY  )");
  } else {
    $check_products_query = tep_db_query("select count(p.products_id) as count 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 = '" . $new_products_category_id . "' and p.products_status = '1' and products_date_added > SUBDATE( now(  ) ,  INTERVAL " . $days . "  DAY  ) limit " . MAX_DISPLAY_NEW_PRODUCTS);
  }
$check_new_products = tep_db_fetch_array($check_products_query);
if ($check_new_products['count'] < "1") {
echo "<br><!-- new_products_disabled //--><br>";
} else {
?>
<!-- New Product Expire_eof //-->
<?php
$info_box_contents = array();
// $info_box_contents[] = array('text' => sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')));
   $info_box_contents[] = array('text' => sprintf(TABLE_HEADING_EXPIRE_NEW_PRODUCTS, strftime('%B')));

new contentBoxHeading($info_box_contents);  
  if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
?>
<!-- New Product Expire //-->
<?php
    $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 p.products_date_added > SUBDATE( now(  ) ,  INTERVAL " . $days . "  DAY  ) and p.products_status = '1' and 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_date_added > SUBDATE( now(  ) ,  INTERVAL " . $days . "  DAY  ) and p.products_status = '1' and 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);
  }
?>
<!-- New Product Expire_eof //-->
<?php


***2. approox. line 42, look for:

  new contentBox($info_box_contents);

right after this line, add:
}



####################################################
#Step 4: catalog/includes/boxes/whats_new.php      #
####################################################

about line 13, find

  if ($random_product = tep_random_select("select products_id, products_image, products_tax_class_id, products_price from " . TABLE_PRODUCTS . " where products_status = '1' order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) {

and replace with:

$days = EXPIRE_NEW_PRODUCTS;
  if ($random_product = tep_random_select("select products_id, products_image, products_tax_class_id, products_date_available, products_price from " . TABLE_PRODUCTS . " where products_date_added > SUBDATE( now(  ) ,  INTERVAL " . $days . "  DAY  ) and products_status = '1' order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) {


####################################################
#Step 5: catalog/includes/languages/danish.php     #
####################################################

add this:

// Contol New Products
define('TABLE_HEADING_EXPIRE_NEW_PRODUCTS', 'Nye produkter tilføjet de sidste ' . EXPIRE_NEW_PRODUCTS . ' dage.');

just before:

?>

####################################################
#Step 5: catalog/includes/languages/english.php     #
####################################################

add this:

// Contol New Products
define('TABLE_HEADING_EXPIRE_NEW_PRODUCTS', 'New Products added within the last ' . EXPIRE_NEW_PRODUCTS . ' days.');

just before:

?>

******* Done. Enjoy. And, of course, you DID back up your files before making this modifications, DIDN'T YOU!!

Any problems, email me at gsnell@ameriwebs.com. I'll do my best to help, BUT, as the contributions board so aptly states,
use all contributions at your own risk!

####################################################################
Control New Products module for 2.2-MS2
-----------------------------

By default, OsCommerce shows the latest added items as new items both on the startpage and on the category pages.
The box says ex. "New products in May" wich might be the case if you added those items in May.
But the default version of OsC does not handle when to remove these items from the "New products in.." box.
If you are not frequently adding new items to your shop, this looks pretty dull after a while, since the same products
lay there all the time.

This Mod lets lets you choose for how long newly added items should be shown in the "New products in.." box on the frontpage.
Default is 30 days, but it can be changed to that ever you like.

See comments in new_products.php for more info.

Installation of the script is very straightforward, but remember to BACKUP the relevant files before you change anything.

Enjoy!


Zipper - Sweden
zipper@smartsite.nu

Installation
------------------------------
Very simple, just make a backup copy of the file
/catalog/includes/modules/new_products.php
Copy the file new_products.php in this .zip file to /catalog/includes/modules/
Change the options available in your new new_products.php

You are done!


Changing the number of days and other alternatives.
------------------------------
See comments in new_products.php

Écrit par : croco 5 Apr 2012, 22:34

Personne pour filer un petit coup de main à un débutant ? smile.gif

Écrit par : Bonbec 6 Apr 2012, 06:07

Bonjour,

Je ne connais pas cette contrib mais je veux bien essayer de t'aider happy.gif

Citation (croco @ 1 Apr 2012, 22:57) *
...J'en suis donc venu à la conclusion qu'il fallait que je fasse les modifications à la main

Exact.

Citation (croco @ 1 Apr 2012, 22:57) *
... Il y a un fichier .sql il faut donc l'éxecuter via phpmyadmin mais dans le readme l'auteur dis de sauter cette étape si j'ai bien compris ???
SKIP! Step 1 if you use the Contol_New_Products-sql.sql Then you can define EXPIRE_NEW_PRODUCTS in
your admin shop in configuration/Control New Products [New products in..]

Il te laisse le choix :
- soit d'utiliser le fichier sql pour paramétrer cela via la BDD
- soit de le coder en dur dans un fichier

Citation (croco @ 1 Apr 2012, 22:57) *
... De plus ensuite il semble expliquer encore une nouvelle méthode d'installation à la fin du readme ????

A priori ne pas tenir compte de ces lignes (ce doit être un reliquat d'une ancienne version) :

Installation
------------------------------
Very simple, just make a backup copy of the file
/catalog/includes/modules/new_products.php
Copy the file new_products.php in this .zip file to /catalog/includes/modules/
Change the options available in your new new_products.php

You are done!

Écrit par : croco 6 Apr 2012, 09:55

Bonjour,

Encore une fois merci car tu es le seul à avoir pris la peine de m'aider dans mes 2 topics, c'est très sympa de ta part smile.gif

Maintenant que j'ai eu tes explications c'est déjà plus clair au niveau de l'installation, notamment sur la dernière partie qui n'est à prioris plus d'actualité.

Restant un débutant je préfére toujours éviter de toucher à la base de donnée car mon site est en production et j'ai toujours peur de faire une erreur irréparable (malgré que je backup toujours ma BDD avant chaque modif).

Ma dernière question va donc être:

Ques-ce qui est le mieux et le plus simple pour moi ?

Utiliser le fichier sql pour paramétrer cela via la BDD ou le coder en dur dans un fichier ?

Encore merci smile.gif

Écrit par : Bonbec 6 Apr 2012, 10:29

Re,

Pour l'aide, tu as la chance que je m'énerve après un produit que je n'arrive pas à fabriquer correctement, alors je me change les idées avant de tout casser biggrin.gif

Perso je préfèrerais pouvoir faire la modif dans la BDD si une interface est prévue dans le script (je ne l'ai pas installé sur mon site). Dans un fichier, si tu ne te souviens plus dans quel fichier cela se trouve, le jour où tu voudras faire une modif ... ben t'es pas dans la m.... wacko.gif

Sinon tu devrais faire tes bidouilles en local sur ton ordi et quand çà fonctionne basculer sur le site en production ...

Écrit par : croco 6 Apr 2012, 10:46

lol

Ok donc le mieux reste de mettre ça dans la BDD, je copie colle le contenu du fichier et je le colle dans la partie requête de phpmyadmin et l’exécute.


J'ai une boutique de test en ligne mais faut que je la mette à jour, je vais m'en occuper et tester dessus.

Encore milles merci car grâce à toi je peux passer ce topic en résolu smile.gif

Je viendrais quand même poster mon retour une fois la contrib installée pour indiquer si ça fonctionne bien ou non chez moi.

++

Écrit par : croco 6 Apr 2012, 20:40

Bon pour l'instant j'ai juste mis la requête SQL, ça c'est bien passé.

Le soucis c'est que ça m'a ajouté juste une ligne dans la configuration permettant de modifier le nombre de jour, si je veux par exemple laisser les produits 30j ou plus.

Le truc c'est que moi c'est pas ça que je recherche, je veux pouvoir mettre les produits que je veux dedans et en voyant ce que ça mis comme option dans le panel administration je commence à douter fortement que cette contribution permettent de faire ça.

J'aurais peut-être dut me renseigner un peu mieux avant.

Enfin si quelqu'un peut confirmer ça serait pas plus mal.

Merci smile.gif

++

Écrit par : Bonbec 6 Apr 2012, 21:24

Re,

La description de la contrib précise qu'OsCommerce que si tu n'ajoutes pas régulièrement de nouveaux articles, cela t'affiche des "nouveaux produits" qui restent affichés depuis des lustres, donc çà donne l'impression que ton site dort.
La contrib te permet juste de préciser un nombre de jours maxi d'affichage des nouveaux produits au cas où tu n'en rajouterais pas entretemps.

SI j'ai bien compris, tu veux choisir quels articles afficher, c'est çà ?

Écrit par : croco 6 Apr 2012, 23:18

Oui tout à fait, je voudrais pouvoir choisir moi même les produits et si possible modifier le nom de la boxe en "A voir absolument"

Merci smile.gif

Écrit par : Bonbec 6 Apr 2012, 23:27

Re,

Regarde http://addons.oscommerce.com/info/651, elle semble correspondre à ce que tu cherches à faire.

Écrit par : croco 6 Apr 2012, 23:30

Youpi !

C'est exactement ça que je cherche justement wub.gif

Merci une fois de plus biggrin.gif

Propulsé par Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)