xavpiaf Posted September 27, 2010 Posted September 27, 2010 Bonjour,Je voudrais limiter le nombre de produits afficher , sur la page produit dans l'espace dédié aux produits de la même catégories.Je voudrais seulement en afficher 4.Voici mon code : {if count($categoryProducts) > 0} {foreach from=$categoryProducts item='categoryProduct' name=categoryProduct} {if $categoryProduct.index > 4} TATATATATATA {else} {if $categoryProduct.new == 1}{l s='New'} {/if} {if $categoryProduct.on_sale} {l s='On sale!'} {elseif ($categoryProduct.reduction_price != 0 || $categoryProduct.reduction_percent != 0) && ($categoryProduct.reduction_from == $categoryProduct.reduction_to OR ($smarty.now|date_format:'%Y-%m-%d' <= $categoryProduct.reduction_to && $smarty.now|date_format:'%Y-%m-%d' >= $categoryProduct.reduction_from))} {l s='Price lowered!'} {convertPrice price=$categoryProduct.price_without_reduction} {/if} {if ($categoryProduct.quantity > 0)} {if $categoryProduct.quantity == 0}{if $allow_oosp}{$categoryProduct.available_later}{else}{/if}{else}{$categoryProduct.available_now}{/if}{else} 0}{elseif $categoryProduct.allow_oosp}{l s=$categoryProduct.available_later} style="display:none;"{/if}> {l s='Out of stock'} {if $categoryProduct.quantity > 0}{elseif $categoryProduct.allow_oosp}{l s=$categoryProduct.available_later}{/if} {/if} getProductLink($categoryProduct.id_product, $categoryProduct.link_rewrite, $categoryProduct.category)}" title="{$categoryProduct.name|htmlspecialchars}"> getImageLink($categoryProduct.link_rewrite, $categoryProduct.id_image, 'large')}" alt="{$categoryProduct.name|htmlspecialchars}" /> getProductLink($categoryProduct.id_product, $categoryProduct.link_rewrite, $categoryProduct.category, $categoryProduct.ean13)}" title="{$categoryProduct.name|htmlspecialchars}">{$categoryProduct.name|truncate:25:'...'|escape:'htmlall':'UTF-8'} getProductLink($categoryProduct.id_product, $categoryProduct.link_rewrite, $categoryProduct.category)}" title="{$categoryProduct.name|htmlspecialchars}" title="{l s='More' mod='productscategory'}">{$categoryProduct.description_short|strip_tags|truncate:140s:'...'} {displayWtPrice p=$categoryProduct.price} getProductLink($categoryProduct.id_product, $categoryProduct.link_rewrite, $categoryProduct.category)}" title="{$categoryProduct.name|htmlspecialchars}" title="{l s='View' mod='productscategory'}">{l s='View' mod='productscategory'} {/if} {/foreach} {/if} Merci d'avance pour vos réponsesCordialement, Share this post Link to post Share on other sites More sharing options...
xavpiaf Posted September 28, 2010 Posted September 28, 2010 Juste un message pour remonter mon post.Pas de réponse à me donner??? Share this post Link to post Share on other sites More sharing options...
Yannkee Posted October 1, 2010 Posted October 1, 2010 {if $smarty.foreach.categoryProduct.index < 4} ca devrait etre mieux Share this post Link to post Share on other sites More sharing options...
Blanco Posted November 16, 2010 Posted November 16, 2010 I have the same request. Can you help me please? {if count($categoryProducts) > 0} {foreach from=$categoryProducts item='categoryProduct' name=categoryProduct} {if $categoryProduct.new == 1}{l s='new'} {/if} {if $categoryProduct.on_sale} {l s='On sale!'} {elseif ($categoryProduct.reduction_price != 0 || $categoryProduct.reduction_percent != 0) && ($categoryProduct.reduction_from == $categoryProduct.reduction_to OR ($smarty.now|date_format:'%Y-%m-%d' <= $categoryProduct.reduction_to && $smarty.now|date_format:'%Y-%m-%d' >= $categoryProduct.reduction_from))} {l s='Price lowered!'} {convertPrice price=$categoryProduct.price_without_reduction} {/if} {if ($categoryProduct.quantity > 0)} {if $categoryProduct.quantity == 0}{if $allow_oosp}{$categoryProduct.available_later}{else}{/if}{else}{$categoryProduct.available_now}{/if}{else} 0}{elseif $categoryProduct.allow_oosp}{l s=$categoryProduct.available_later} style="display:none;"{/if}> {l s='Out of stock'} {if $categoryProduct.quantity > 0}{elseif $categoryProduct.allow_oosp}{l s=$categoryProduct.available_later}{/if} {/if} getProductLink($categoryProduct.id_product, $categoryProduct.link_rewrite, $categoryProduct.category)}" title="{$categoryProduct.name|htmlspecialchars}"> getImageLink($categoryProduct.link_rewrite, $categoryProduct.id_image, 'large')}" alt="{$categoryProduct.name|htmlspecialchars}" /> getProductLink($categoryProduct.id_product, $categoryProduct.link_rewrite, $categoryProduct.category, $categoryProduct.ean13)}" title="{$categoryProduct.name|htmlspecialchars}">{$categoryProduct.name|truncate:25:'...'|escape:'htmlall':'UTF-8'} getProductLink($categoryProduct.id_product, $categoryProduct.link_rewrite, $categoryProduct.category)}" title="{$categoryProduct.name|htmlspecialchars}" title="{l s='More' mod='productscategory'}">{$categoryProduct.description_short|strip_tags|truncate:140s:'...'} {displayWtPrice p=$categoryProduct.price} getProductLink($categoryProduct.id_product, $categoryProduct.link_rewrite, $categoryProduct.category)}" title="{$categoryProduct.name|htmlspecialchars}" title="{l s='View' mod='productscategory'}">{l s='View' mod='productscategory'} {/foreach} {/if} Share this post Link to post Share on other sites More sharing options...
Blanco Posted November 17, 2010 Posted November 17, 2010 Help? Please?? Share this post Link to post Share on other sites More sharing options...
dangee Posted December 31, 2010 Posted December 31, 2010 Pour limiter le nombre de produits à afficher dans le module "Dans la même catégorie", c'est très simple :Editer le fichier "productscategory.php" qui se trouve dans "/modules/productscategory".Modifier comme suit :ligne 51 : $sizeOfCategoryProducts = $category->getProducts(intval($cookie->id_lang), 1, 30, NULL, NULL, true); par $sizeOfCategoryProducts = $category->getProducts(intval($cookie->id_lang), 1, 5, NULL, NULL, true); ligne 85 : if ($sizeOfCategoryProducts > 30) { $categoryProducts = array_slice($categoryProducts, $middlePosition - 15, 30, true); $middlePosition = 15; par if ($sizeOfCategoryProducts > 5) { $categoryProducts = array_slice($categoryProducts, $middlePosition - 3, 5, true); $middlePosition = 3; Ici le nombre de produits sera limité à 5 1 Share this post Link to post Share on other sites More sharing options...
p.guerin Posted May 27, 2015 Posted May 27, 2015 Pourriez vous actualiser votre réponse pour prestashop 1.6 ? merci Share this post Link to post Share on other sites More sharing options...
mik69 Posted July 18, 2015 Posted July 18, 2015 Pourriez vous actualiser votre réponse pour prestashop 1.6 ? merci à la ligne $category_products = $category->getProducts($this->context->language->id, 1, 100); /* 100 products max. */ Remplacer la valeur 100 par ce que désiré Share this post Link to post Share on other sites More sharing options...
kerlin Posted October 4, 2018 Posted October 4, 2018 Bonjour Mik69, merci pour cette astuce ! et pour 1.7, cela donnerait quoi ? Merci d'avance ! Share this post Link to post Share on other sites More sharing options...
kerlin Posted October 4, 2018 Posted October 4, 2018 Vieux topic déterré mais ça peut servir. Sur 1.7, c'est simplissime. C'est toujours dans le même fichier mais il y a une valeur à modifier dans une (). Et un commentaire à côté explique le nombre à mettre pour afficher x produits. Share this post Link to post Share on other sites More sharing options...
ebadoit Posted January 3, 2021 Posted January 3, 2021 Bonjour, J'ai le même problème avec prestashop 1.7. J'ai l'impression que cela dégrade les temps de réponse de certaines pages de mon site car certaines catégories comprennent beaucoup d'article. exemple ici : https://sowaxtendance.fr/kimono-wax/23-kimono-wax-simi-en-tissu-africain-.html Je ne vois pas comment adapter le fichier productscategory.php pour limiter à 5 articles par exemple. Est ce possible d'effectuer cette modification dans le back office sans toucher aux fichiers ? Par avance, merci de votre aide. Share this post Link to post 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