AngelDisc Posted January 18, 2010 Share Posted January 18, 2010 Bonjour, je cherche un moyen de créer un module pour afficher le top 20 des ventes sur la page d'accueil .Quelqu'un aurait il un bout de code existant ou une idée pour me guider ?Merci Link to comment Share on other sites More sharing options...
SmartiesKiller Posted January 18, 2010 Share Posted January 18, 2010 adapte le code que j'ai mis pour les promotions au lieu d'en afficher 4 tu recopie le code autant de fois que tu en as besoin.si besoin j'm'y pencherais dessus. Link to comment Share on other sites More sharing options...
AngelDisc Posted January 26, 2010 Author Share Posted January 26, 2010 Bonjour à tous,et merci d'avance pour votre aide.Suite à beaucoup de recherche, j'ai encore pas mal de bug ( soyez indulgent, c'est la première fois que je programme )Bugs:# Nombre de meilleurs ventes n'est pas prit en compte# Images affiché corresponde à la meilleur vente alors que les titres sont modifiéhomebestsellers.php: <?php class HomeBestsellers extends Module { private $_html = ''; private $_postErrors = array(); function __construct() { $this->name = 'homebestsellers'; $this->tab = 'Tools'; $this->version = 0.0; parent::__construct(); $this->displayName = $this->l('TOP 20 des ventes'); $this->description = $this->l('Ajoute sur la page d´accueil les 20 meilleurs ventes'); } public function install() { if (!parent::install() OR !$this->registerHook('home') OR !$this->registerHook('updateOrderStatus') OR !ProductSale::fillProductSales()) return false; return true; } public function getContent () { $output = ''.$this->displayName.''; if (Tools::isSubmit('submitHomeBestSellers')) { if (!$homebestsellersNbr = Tools::getValue('homebestsellersNbr') OR empty($homebestsellersNbr)) $output .= ''.$this->l('Vous devez remplir le champ "Meilleurs vente affichés"').''; elseif (intval($homebestsellersNbr) == 0) $output .= ''.$this->l('Nombre incorrecte.').''; else { Configuration::updateValue('HOMEBESTSELLERS_NBR', intval($homebestsellersNbr)); $output .= 'l('Confirmation').'" />'.$this->l('Settings updated').''; } } return $output.$this->displayForm(); } public function displayForm() { $output = ' <form action="'.$_SERVER['REQUEST_URI'].'" method="post"> _path.'logo.gif" alt="" title="" />'.$this->l('Paramètres').' '.$this->l('Meilleurs vente affichés').' <input type="text" name="homebestsellersNbr" value="'.intval(Configuration::get('HOMEBESTSELLERS_NBR')).'" /> '.$this->l('Définir le nombre de meilleurs ventes à afficher dans le module').' <input type="submit" name="submitHomeBestSellers" value="'.$this->l('Sauvegarder').'" class="button" /> </form>'; return $output; } function hookHome($params) { global $smarty; $currency = new Currency(intval($params['cookie']->id_currency)); $bestsellers = ProductSale::getBestSalesLight(intval($params['cookie']->id_lang), 0, 5); $best_sellers = array(); foreach ($bestsellers AS $bestseller) { $bestseller['price'] = Tools::displayPrice(Product::getPriceStatic(intval($bestseller['id_product'])), $currency); $best_sellers[] = $bestseller; } $smarty->assign(array( 'best_sellers' => $best_sellers, 'mediumSize' => Image::getSize('medium'))); return $this->display(__FILE__, 'homebestsellers.tpl'); } } ?> homebestsellers.tpl: <!-- MODULE TOP 20 --> <!-- {l s='Bike Mamba Top 20' mod='homebestsellers'} --> {if $best_sellers|@count > 0} {foreach from=$best_sellers item=product name=myLoop} {$product.name} getImageLink($best_sellers.0.link_rewrite, $best_sellers.0.id_image, 'medium')}" height="{$mediumSize.height}" width="{$mediumSize.width}" alt="{$best_sellers.0.legend}" /> {/foreach} <!-- {l s='All best sellers' mod='blockbestsellers'} --> {else} {l s='No best sellers at this time' mod='blockbestsellers'} {/if} <!-- /MODULE TOP 20 --> ajouter à global.css: /************* TOP 20 *************/ #top20{ float:left; width:270px; height:200px; border: solid 1px #ffffff; margin:5px; } Par la suite je vais essayer de mettre "Ajouter au panier"Merci de votre aide mon site: http://www.bikemamba.fr/ Link to comment Share on other sites More sharing options...
SmartiesKiller Posted January 26, 2010 Share Posted January 26, 2010 cool,fait donc un ptit zip pour pouvoir le mettre sur prestatools etc etc ,n'oublie pas de mettre un ptit screen shoot pour les personnes qui ne savent pas trop ce que fait ton code. Link to comment Share on other sites More sharing options...
AngelDisc Posted January 26, 2010 Author Share Posted January 26, 2010 Pas de problème, une fois mes problèmes réglés,je ferais ça avec plaisir ...en espérant juste régler les erreur cité plus haut.++ Vins Link to comment Share on other sites More sharing options...
AngelDisc Posted January 27, 2010 Author Share Posted January 27, 2010 Bonjour.J'ai modifier le fichier homebestsellers de manière a imposer un nombre maximum de meilleurs ventes en page d'accueil <?php class HomeBestsellers extends Module { private $_html = ''; private $_postErrors = array(); function __construct() { $this->name = 'homebestsellers'; $this->tab = 'Tools'; $this->version = 0.0; parent::__construct(); $this->displayName = $this->l('TOP 20 des ventes'); $this->description = $this->l('Ajoute sur la page d´accueil les 20 meilleurs ventes'); } function install() { if (!parent::install() OR !$this->registerHook('home') OR !Configuration::updateValue('HOMEBESTSELLERS_NBR', 20)) return false; return true; } public function getContent() { $output = ''.$this->displayName.''; if (Tools::isSubmit('submitHomeBestSellers')) { if (!$homebestsellersNbr = Tools::getValue('homebestsellersNbr') OR empty($homebestsellersNbr)) $output .= ''.$this->l('You must fill in the \'Products displayed\' field').''; elseif (intval($homebestsellersNbr) == 0) $output .= ''.$this->l('Invalid number.').''; elseif (intval($homebestsellersNbr) > 20) $output .= ''.$this->l('Invalid number.').''; else { Configuration::updateValue('HOMEBESTSELLERS_NBR', intval($homebestsellersNbr)); $output .= 'l('Confirmation').'" />'.$this->l('Settings updated').''; } } return $output.$this->displayForm(); } public function displayForm() { $output = ' <form action="'.$_SERVER['REQUEST_URI'].'" method="post"> _path.'logo.gif" alt="" title="" />'.$this->l('Settings').' '.$this->l('Best sellers displayed').' <input type="text" name="homebestsellersNbr" value="'.intval(Configuration::get('HOMEBESTSELLERS_NBR')).'" /> '.$this->l('Define the number of products displayed in this module').' <input type="submit" name="submitHomeBestSellers" value="'.$this->l('Save').'" class="button" /> </form>'; return $output; } function hookHome($params) { global $smarty; $currency = new Currency(intval($params['cookie']->id_currency)); $bestsellers = ProductSale::getBestSalesLight(intval($params['cookie']->id_lang), 0, 5); $best_sellers = array(); foreach ($bestsellers AS $bestseller) { $bestseller['price'] = Tools::displayPrice(Product::getPriceStatic(intval($bestseller['id_product'])), $currency); $best_sellers[] = $bestseller; } $smarty->assign(array( 'best_sellers' => $best_sellers, 'mediumSize' => Image::getSize('medium'))); return $this->display(__FILE__, 'homebestsellers.tpl'); } } ?> Par contre j'ai toujours un problème de retour de variable pas prit en compte, comment puis je faire pour connaitre le nombre de meilleurs ventes indiqué lors de mon installation de module et qui apparaitrai dans mon fichier *.tpl ?Merci du coup de main.Vincent Link to comment Share on other sites More sharing options...
Thibaut24 Posted May 2, 2010 Share Posted May 2, 2010 Salut Vins,As tu regardé le module de Olecorre, tu pourras peut être trouvé de l'aide en le décortiquant un peu ? http://www.oboutique.fr/prestamodules/15-carroussel-des-meilleures-ventes-v2.htmlhttp://www.prestashop.com/forums/viewthread/41793/modules_tiers/module_module_des_meilleures_ventes_avec_caroussel_v2Bon courage Thibaut Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now