FrancisParent Posted April 26, 2014 Share Posted April 26, 2014 (edited) Bonjour à tous, Un de mes clients avait le besoin de grouper l'affichage des produits par catégorie sous la page manufacturier, de sorte à avoir une affichage au format suivant: Manufacturier Catégorie Produit 1 Produit 2 Produit 3 etc.. Autre Catégorie Produit 1 Produit 2 Produit 3 etc.. J'ai fait des recherches sans rien trouver de concluent et je désire partager avec vous la solution que j'ai apporté. Modifications à la fonction " assignOne()" du fichier ManufacturerController.php protected function assignOne() { $this->manufacturer->description = Tools::nl2br(trim($this->manufacturer->description)); $nbProducts = $this->manufacturer->getProducts($this->manufacturer->id, null, null, null, $this->orderBy, $this->orderWay, true); $this->pagination((int)$nbProducts); //var_dump($this->category); $products = $this->manufacturer->getProducts($this->manufacturer->id, $this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay); $products_local = array(); $categproducts = array(); $categ_local = array(); $categories = Category::getHomeCategories($this->context->cookie->id_lang, false); foreach($products as $k=>$v){ $id_product = $v['id_product']; $products_local[$id_product] = $v; } foreach($categories as $k=>$v){ $id_category = $v['id_category']; $categ_local[$id_category] = $v; $this->category = new Category($id_category, $this->context->language->id); //$prods = $this->category->getProducts(null, null, null, $this->orderBy, $this->orderWay, true); $prods = $this->category->getProducts($this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay); foreach ($prods as $key => $val) { $id_product = $val['id_product']; if(isset($products_local[$id_product])){ if(!isset($categproducts[$id_category])) $categproducts[$id_category] = array(); $categproducts[$id_category][$id_product] = $val; } } } Modifications au fichier manufacturer.tpl {if isset($products)} <div id="product_list" class="grid_view clear"> {assign var=maxitem value=4} {foreach from=$categproducts key=k item=v} <div class="manufcategwrapper"> <h3 class="manufcategtitle">{$categ_titles[$k].name|escape:html:'UTF-8'}</h3> {assign var=count value=0} {foreach from=$v item=product name=products} {if $count < $maxitem} {if $product@iteration%4==1} <ul class="product-grid row-fluid"> {/if} <li class="ajax_block_product span3 {if $smarty.foreach.products.first}first_item{elseif $smarty.foreach.products.last}last_item{/if} {if $smarty.foreach.products.index % 2}alternate_item{else}item{/if} clearfix"> <div class="item-inner"> <a id = "bigpic_{$product.id_product}" href="{$product.link|escape:'html'}" title="{$product.name|escape:html:'UTF-8'}" class="product_image"> <img id="bigpic" src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'pos_product')|escape:'html'}" alt="{$product.name|escape:html:'UTF-8'}" /> <!-- {if isset($product.new) && $product.specific_prices} {if $product.specific_prices} <span class="sale">{l s='Sale'}</span>{/if} {else} {if isset($product.new) && $product.new == 1} <span class="new">{l s='New'}</span> {/if} {if $product.specific_prices} <span class="sale">{l s='Sale'}</span> {/if} {/if} --> </a> <div class="rubino_product_list_info"> <div class="rubino_product_list_info_row"> <a href="{$product.link|escape:'html'}" title="{$product.name|truncate:50:'...'|escape:'htmlall':'UTF-8'}">{$product.name|truncate:28:'...'|escape:'htmlall':'UTF-8'}</a> <span class="rub_price_list">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span> </div> </div> </div> </li> {if $product@iteration%4==0||$smarty.foreach.products.last} </ul> {/if} {/if} {assign var=count value=$count++} {/foreach} <a href="{$link->getCategoryLink($k)}">{l s='See all'} {$categ_titles[$k].name|escape:html:'UTF-8'}</a> </div><!-- end manufcategwrapper --> {/foreach} </div> {/if} Si vous désirez plus de détails à propos de cette solution ou télécharger le code je vous invite à consulter l'article que j'ai écrit sur mon blogue: http://www.francisparent.com/prestashop-affichage-produits-groupes-categorie-page-manufacturier/ Edited April 26, 2014 by FrancisParent (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