MwC Posted October 15, 2012 Share Posted October 15, 2012 Bonjour, J'essais d'afficher plus de produits en promotions sur la page d'accueil via le module TM Specials block v1.0 par TM sur une boutique sous prestashop 1.4.6.2. http://eshop.glissevolution.com/ Je pensais qu'en changeant la valeur de {if $smarty.foreach.products.iteration<=14} cela ferais l'affaire, mais apparemment il existe un maximum d'articles affichables... car en dessous de 10 produits cela fonctionne, mais dès que je définie une valeur au dessus de 10 il ne veut rien savoir. A savoir qu'il m'affiche toujours les même produits et dans le même ordre. Merci par avance. Les code du fichier tmspecials.tpl : <!-- MODULE Block specials --> <div id="tmspecials" class="block"> <h4><a href="{$link->getPageLink('prices-drop.php')}" title="{l s='Specials' mod='tmspecials'}">{l s='Specials' mod='tmspecials'}</a></h4> <div class="block_content"> <ul> {foreach from=$products item=product name=products} {if $smarty.foreach.products.iteration<=14} <li class="ajax_block_product spec{cycle values='1,2,3,4'}"> <a class="product_img_link" href="{$product.link}"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home')}" alt="{$product.legend|escape:html:'UTF-8'}" title="{$product.name|escape:html:'UTF-8'}" /></a> <h5><a href="{$product.link}" title="{$product.name|escape:html:'UTF-8'}">{$product.name|escape:html:'UTF-8'}</a></h5> <span class="price">{if !$priceDisplay}{displayWtPrice p=$product.price}{else}{displayWtPrice p=$product.price_tax_exc}{/if}</span> <span class="on_sale"> - {number_format(((($product.price_without_reduction - $product.price) / $product.price_without_reduction) * 100), 0)}% </span><span class="price-discount"> {if !$priceDisplay}{displayWtPrice p=$product.price_without_reduction}{else}{displayWtPrice p=$priceWithoutReduction_tax_excl}{/if}</span> <div> {if ($product.id_product_attribute == 0 || (isset($add_prod_display) && ($add_prod_display == 1))) && $product.available_for_order && !isset($restricted_country_mode) && !$PS_CATALOG_MODE} {if ($product.allow_oosp || $product.quantity > 0) && $product.customizable != 2} <a class="exclusive ajax_add_to_cart_button" rel="ajax_id_product_{$product.id_product|intval}" href="{$link->getPageLink('cart.php')}?add&id_product={$product.id_product|intval}{if isset($static_token)}&token={$static_token}{/if}" title="{l s='Add to cart'}">{l s='Ajouter au panier' mod='tmspecials'}<span> ></span></a> {else} <span class="exclusive">{l s='Ajouter au panier' mod='tmspecials'}<span> ></span></span> {/if} {/if} </div> </li> {/if} {/foreach} </ul> </div> </div> <!-- /MODULE Block specials --> Link to comment Share on other sites More sharing options...
MwC Posted October 16, 2012 Author Share Posted October 16, 2012 Personne n'a une idée pour afficher plus de produits sur un module ? La fonction {if $smarty.foreach.products.iteration<=14} est limitée à 10 produits impossible d'en ajouter plus ni de choisir l'ordre et les produits. Link to comment Share on other sites More sharing options...
jujutte24 Posted January 19, 2013 Share Posted January 19, 2013 Salut ! tu as trouvé une solution ? Link to comment Share on other sites More sharing options...
Bondaty and Co Posted January 21, 2013 Share Posted January 21, 2013 fait une recherche dans la base de donnée sur : iteration Link to comment Share on other sites More sharing options...
jujutte24 Posted January 21, 2013 Share Posted January 21, 2013 Ben j'ai fait quelques recherches, mais je ne trouve rien de concluant. Je ne comprends pas pourquoi les produits en promos affichés sont toujours les même... Link to comment Share on other sites More sharing options...
jujutte24 Posted January 24, 2013 Share Posted January 24, 2013 (edited) je rajoute le bout de code du fichier php: { if (Configuration::get('PS_CATALOG_MODE')) return ; global $smarty; $smarty->assign(array( 'special' => $special, 'products' => Product::getPricesDrop(intval($params['cookie']->id_lang)), 'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'] / (1 + (int)$special['rate'] / 100), 2), )); return $this->display(__FILE__, 'tmhomespecials.tpl'); } } J'ai essayé de mettre le code shuffle($products); Mais ça me fait une page blanche.... je nage... comment faire pour afficher les promos de façon aléatoires.... j'ai toujours les même 4 produits.... si vous avez une idée elle est la bienvenue Edited January 24, 2013 by jujutte24 (see edit history) Link to comment Share on other sites More sharing options...
jujutte24 Posted January 28, 2013 Share Posted January 28, 2013 Help ! s'il vous plait, un peu d'aide....je nage depuis des jours et des jours Link to comment Share on other sites More sharing options...
Floklo Posted February 7, 2013 Share Posted February 7, 2013 (edited) Bonjour. As-tu trouvé une solution ? J'ai exactement le même problème ... Cordialement. Edited February 7, 2013 by Floklo (see edit history) Link to comment Share on other sites More sharing options...
Floklo Posted February 7, 2013 Share Posted February 7, 2013 Je viens de trouver une solution pour qu'il prenne les dernières promotions et non les premières (donc à chaque nouvelle promo il les affichera) dans tmspecials.php public function hookHome($params) { if (Configuration::get('PS_CATALOG_MODE')) return ; global $smarty; $tmp = Product::getPricesDrop(intval($params['cookie']->id_lang), 0, '12', false, '', 'ASC'); asort($tmp); if (!$special = Product::getPricesDrop((int)($params['cookie']->id_lang), 0, '12', false, '', 'ASC') AND !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY')) return; $smarty->assign(array( 'special' => $special, 'specials' => $tmp, 'products' => Product::getPricesDrop(intval($params['cookie']->id_lang), 0, '12', false, '', 'ASC'), 'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2) )); return $this->display(__FILE__, 'tmspecials.tpl'); } Par contre impossible de mettre plus de 12 ... si quelqu'un à une piste je suis preneur (même en modifiant 12 cela ne fonctionne pas). Link to comment Share on other sites More sharing options...
jujutte24 Posted February 7, 2013 Share Posted February 7, 2013 (edited) Super, je vais tester. Ce qui serait bien c'est qu'il puisse faire une sorte de "random" des produits en promo, comme le bloc natif prestashop. Mais là ça dépasse mes compétences.... De plus, il serai judicieux qu'il affiche l'ancien prix barré, ce qui n'est pas le cas sur le miens... Edited February 7, 2013 by jujutte24 (see edit history) Link to comment Share on other sites More sharing options...
jujutte24 Posted February 7, 2013 Share Posted February 7, 2013 Bon, j'ai fait la modif, mais ça m'efface carrément le module, il est plus affiché en front office.... Link to comment Share on other sites More sharing options...
Floklo Posted February 8, 2013 Share Posted February 8, 2013 Tu as remplacer toute la fonction existante dans ton fichier par la mienne et cela ne fonctionne pas ? Peut être que tu as une version différente, pourrais tu passer le code de la fonction que l'on voit cela ? Link to comment Share on other sites More sharing options...
jujutte24 Posted February 8, 2013 Share Posted February 8, 2013 (edited) <?php if (!defined('_CAN_LOAD_FILES_')) exit; class TMHomeSpecials extends Module { private $_html = ''; private $_postErrors = array(); function __construct() { $this->name = 'tmhomespecials'; $this->tab = 'pricing_promotion'; $this->version = 1.0; $this->author = 'TM'; $this->need_instance = 0; parent::__construct(); $this->displayName = $this->l('TM Home Specials'); $this->description = $this->l('Adds a block with current product specials at a homepage'); } public function install() { return (parent::install() AND $this->registerHook('home')); } public function getContent() { $output = '<h2>'.$this->displayName.'</h2>'; if (Tools::isSubmit('submitSpecials')) { Configuration::updateValue('PS_BLOCK_SPECIALS_DISPLAY', (int)(Tools::getValue('always_display'))); $output .= '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="'.$this->l('Confirmation').'" />'.$this->l('Settings updated').'</div>'; } return $output.$this->displayForm(); } public function displayForm() { return ' <form action="'.$_SERVER['REQUEST_URI'].'" method="post"> <fieldset> <legend><img src="'.$this->_path.'logo.gif" alt="" title="" />'.$this->l('Settings').'</legend> <label>'.$this->l('Always display block').'</label> <div class="margin-form"> <input type="radio" name="always_display" id="display_on" value="1" '.(Tools::getValue('always_display', Configuration::get('PS_BLOCK_SPECIALS_DISPLAY')) ? 'checked="checked" ' : '').'/> <label class="t" for="display_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label> <input type="radio" name="always_display" id="display_off" value="0" '.(!Tools::getValue('always_display', Configuration::get('PS_BLOCK_SPECIALS_DISPLAY')) ? 'checked="checked" ' : '').'/> <label class="t" for="display_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label> <p class="clear">'.$this->l('Show the block even if no product is available.').'</p> </div> <center><input type="submit" name="submitSpecials" value="'.$this->l('Save').'" class="button" /></center> </fieldset> </form>'; } public function hookHome($params) { if (Configuration::get('PS_CATALOG_MODE')) return ; global $smarty; $smarty->assign(array( 'special' => $special, 'products' => Product::getPricesDrop(intval($params['cookie']->id_lang)), 'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'] / (1 + (int)$special['rate'] / 100), 2), )); return $this->display(__FILE__, 'tmhomespecials.tpl'); } } Edited February 8, 2013 by jujutte24 (see edit history) Link to comment Share on other sites More sharing options...
Floklo Posted February 8, 2013 Share Posted February 8, 2013 (edited) Alors modifie dans ta fonction hookHome : 'products' => Product::getPricesDrop(intval($params['cookie']->id_lang), 0, '12', false, '', 'ASC'), Et la prochaine fois, met ton code dans une balise code Edited February 8, 2013 by Floklo (see edit history) Link to comment Share on other sites More sharing options...
jujutte24 Posted February 8, 2013 Share Posted February 8, 2013 Oui, excuses moi pour le vite fait mal fait Ça fonctionne Merci beaucoup ! Mais (par ce qu'il faut un mais), une fonction shuffle n'est-elle pas possible ? Link to comment Share on other sites More sharing options...
Floklo Posted February 8, 2013 Share Posted February 8, 2013 Je viens de tester la function shuffle ne fonctionne pas, si tu veux vraiment faire quelque chose pour que ça soit aléatoire il faut que tu fasses comme sur ce lien: http://www.prestashop.com/forums/topic/67765-solveduse-promotions-articles-into-homepage/ MAIS (parce qu'il faut un mais ), il faut l'adapter a ta version de prestashop car la function à modifier diffère selon certaines version. Link to comment Share on other sites More sharing options...
jujutte24 Posted February 8, 2013 Share Posted February 8, 2013 T'es un chef Merci ! 1 Link to comment Share on other sites More sharing options...
Floklo Posted February 8, 2013 Share Posted February 8, 2013 TU peux aussi modifier le nombre de tes produits en modifiant la valeur dans tmspeecials.php et tmspeacials.tpl (remplacer tous les 12 par 30 par ex). Par contre, tu ne verras la modif qu'en supprimant tous les fichiers (sauf index.php) de tools/smarty/compile/ Moi ça fonctionne ! Bonne journée ! Link to comment Share on other sites More sharing options...
jujutte24 Posted March 11, 2013 Share Posted March 11, 2013 (edited) Pour info ça fonctionne pour moi aussi Mais je n'ai plus le descriptif du produit.... merci encore ! Edited March 11, 2013 by jujutte24 (see edit history) 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