Jump to content

Comment afficher des produits en dessous des sous catégories ?


Recommended Posts

Bonjour

 

Dans ma boutique lorsquon clique sur une catégorie on ne voit que la proposition des sous catégorie ,

 

Par exemple je clique sur bagues

 

La page m'affiche le choix entre bagues fantaisies ou bagues plaque or

 

J'aimerais qu'en dessous on puisse voir quand même les produits de ces deux catégories même si on ne clique pas

 

Comment faire ? Modifier le tpl ? Lequel ? Commnt ?

 

Merci !

Link to comment
Share on other sites

Je pense qu'il faut faire une modification ici , mais laquelle ?

 

{if isset($subcategories)}

<!-- Subcategories -->

<div id="subcategories">

<h3>{l s='Subcategories'}</h3>

<ul class="inline_list">

{foreach from=$subcategories item=subcategory}

<li>

<a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$subcategory.name|escape:'htmlall':'UTF-8'}">

{if $subcategory.id_image}

<img src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium')}" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />

{else}

<img src="{$img_cat_dir}default-medium.jpg" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />

{/if}

</a><br />

<a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}">{$subcategory.name|escape:'htmlall':'UTF-8'}</a>

</li>

{/foreach}

</ul>

<br class="clear"/>

</div>

{/if}

 

{if $products}

{include file="$tpl_dir./product-compare.tpl"}

{include file="$tpl_dir./product-sort.tpl"}

{include file="$tpl_dir./product-list.tpl" products=$products}

{include file="$tpl_dir./product-compare.tpl"}

{include file="$tpl_dir./pagination.tpl"}

{elseif !isset($subcategories)}

<p class="warning">{l s='There are no products in this category.'}</p>

{/if}

{elseif $category->id}

<p class="warning">{l s='This category is currently unavailable.'}</p>

{/if}

{/if}

Link to comment
Share on other sites

J'ai aussi tenté ça :

 

Modification du fichier controllers/CategoryContraller.php en dessous de en ligne 152 :

if (isset(self::$cookie->id_compare))

self::$smarty->assign('compareProducts', CompareProduct::getCompareProducts((int)self::$cookie->id_compare));

 

Ajouter :

$subProducts = array();

foreach($subCategories as $subCat)

{

$tmp_cat_obj = new Category($subCat['id_category'], self::$cookie->id_lang);

$subProducts[$subCat['id_category']] = $tmp_cat_obj->getProducts(intval(self::$cookie->id_lang), (int)($this->p), (int)($this->n), $this->orderBy, $this->orderWay);

}

self::$smarty->assign('subProducts', $subProducts);

 

Puis dans le fichier category.tpl de votre theme :

 

{foreach from=$subcategories item=subcat name=subcategories}

<h2>{$subcat.name|upper}</h2>

{if isset($subProducts[$subcat.id_category][0]['name'])}

{include file="$tpl_dir./product-list.tpl" products=$subProducts[$subcat.id_category]}

{include file="$tpl_dir./pagination.tpl"}

{elseif !isset($subProducts[$subcat.id_category][0]['name'])}

<p class="warning">{l s='There are no products in this category.'}</p>

{/if}

{/foreach}

 

si ca aide qq'un qui cherche !

Cordialement.

 

La première partie je l'ai ajouté au php mais la deuxième partie tpl , j'ai beau essayer , modifier différemment ça ne marche pas

 

http://www.prestashop.com/forums/topic/61916-afficher-tous-les-produits-des-sous-categories-dans-la-categorie-parente/page__st__20

 

Mais ça à pas marché

Link to comment
Share on other sites

Bonsoir,

 

Voici ce que j'ai fais de mon côté pour que cela fonctionne :

 

Dans override/controllers/front/CategoryController.php

 

Après

 

 

class CategoryController extends CategoryControllerCore
{

 

J'ai ajouté :

 


/**
* Assign sub categories templates vars
*/
protected function assignSubcategories()
{
parent::assignSubcategories();
if ($subCategories = $this->category->getSubCategories($this->context->language->id))
{
$subProducts = array();
foreach($subCategories as $subCat)
{
$tmp_cat_obj = new Category($subCat['id_category'], $this->context->language->id);
$nbProducts = $tmp_cat_obj->getProducts(null, null, null, $this->orderBy, $this->orderWay, true);
$this->pagination($nbProducts);
$subProducts[$subCat['id_category']] = $tmp_cat_obj->getProducts($this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay);
}
$this->context->smarty->assign(array(
'subcategories' => $subCategories,
'subcategories_nb_total' => count($subCategories),
'subcategories_nb_half' => ceil(count($subCategories) / 2),
'subProducts' => $subProducts
));
}
}

 

Puis dans le fichier category.tpl du thème :

 

{foreach from=$subcategories item=subcat name=subcategories}
<h2>{$subcat.name|upper}</h2>
{if isset($subProducts[$subcat.id_category][0]['name'])}
{include file="$tpl_dir./product-list.tpl" products=$subProducts[$subcat.id_category]}
{include file="$tpl_dir./pagination.tpl"}
{else}
<p class="warning">{l s='There are no products in this category.'}</p>
{/if}
{/foreach}

 

Bon cela fonctionne chez moi mais je ne pense pas que ce soit la meilleure solution... Quelqu'un aurait une meilleure idée ?

 

Cordialement

Edited by Matt75 (see edit history)
Link to comment
Share on other sites

Dans category.tpl

 

J'ai remplacé

{if isset($subcategories)}
       <!-- Subcategories -->
       <div id="subcategories">
           <h3>{l s='Subcategories'}</h3>
           <ul class="inline_list">
           {foreach from=$subcategories item=subcategory}
               <li class="clearfix">
                   <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$subcategory.name|escape:'htmlall':'UTF-8'}" class="img">
                       {if $subcategory.id_image}
                           <img src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium_default')}" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />
                       {else}
                           <img src="{$img_cat_dir}default-medium_default.jpg" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />
                       {/if}
                   </a>
                   <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" class="cat_name">{$subcategory.name|escape:'htmlall':'UTF-8'}</a>
                   {if $subcategory.description}
                       <p class="cat_desc">{$subcategory.description}</p>
                   {/if}
               </li>
           {/foreach}
           </ul>
           <br class="clear"/>
       </div>
       {/if}

 

Par :

 

{foreach from=$subcategories item=subcat name=subcategories}
<h2>{$subcat.name|upper}</h2>
{if isset($subProducts[$subcat.id_category][0]['name'])}
{include file="$tpl_dir./product-list.tpl" products=$subProducts[$subcat.id_category]}
{include file="$tpl_dir./pagination.tpl"}
{else}
<p class="warning">{l s='There are no products in this category.'}</p>
{/if}
{/foreach}

Link to comment
Share on other sites

Avec ton code php j'arrive pas car j'ai pas le même dossier que toi , mais avec ça j'ai réussi :

 

Modification du fichier controllers/CategoryContraller.php en dessous de en ligne 152 :

if (isset(self::$cookie->id_compare))

self::$smarty->assign('compareProducts', CompareProduct::getCompareProducts((int)self::$cookie->id_compare));

 

Ajouter :

$subProducts = array();
foreach($subCategories as $subCat)
{
$tmp_cat_obj = new Category($subCat['id_category'], self::$cookie->id_lang);
$subProducts[$subCat['id_category']] = $tmp_cat_obj->getProducts(intval(self::$cookie->id_lang), (int)($this->p), (int)($this->n), $this->orderBy, $this->orderWay);
}
self::$smarty->assign('subProducts', $subProducts);

 

 

 

Par contre j'ai plus les images des catégories , et j'aimerais qu'il y ai moins de prdouits , genre 4 produits à peu près , juste à titre d'exemple : http://www.bijouifique.com/17-colliers

Edited by Miryam68 (see edit history)
Link to comment
Share on other sites

Y'a écrit précédent et suivant mais c'est pas cliquable , et ce que j'aimerais c'est que l'on puisse quand même cliquer sur la catégorie souhaitée ,

 

En fait les quelques produits doivent juste être à titre d'exemple et pour ne pas avoir une page vide de produits c'est possible ?

Link to comment
Share on other sites

Je suis sur la version 1.5.1, tu n'as peut-être pas la même version.

 

Dans le code php que tu as ajouté, remplace :

$subProducts[$subCat['id_category']] = $tmp_cat_obj->getProducts(intval(self::$cookie->id_lang), (int)($this->p), (int)($this->n), $this->orderBy, $this->orderWay);

 

Par

 

$subProducts[$subCat['id_category']] = $tmp_cat_obj->getProducts(intval(self::$cookie->id_lang), 1, 4, $this->orderBy, $this->orderWay);

 

Change le 4 par le nombre de produit souhaité

 

Dans le code que tu as ajouté dans category.tpl, supprime cette ligne

{include file="$tpl_dir./pagination.tpl"}

Edited by Matt75 (see edit history)
Link to comment
Share on other sites

ah merci oui je suis en 1.4.9 , est-ce que je peux rajouter ça au tpl pour avoir image et lien?

 

{if $subcategory.id_image}
   <img src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium')}" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />
  {else}
   <img src="{$img_cat_dir}default-medium.jpg" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />
  {/if}
 </a><br />
 <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}">{$subcategory.name|escape:'htmlall':'UTF-8'}</a>
   </li>
  {/foreach}
  </ul>
  <br class="clear"/>
 </div>
 {/if}

Link to comment
Share on other sites

Pour image et lien

{if $subcategory.id_image}
          <img src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium')}" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />
         {else}
          <img src="{$img_cat_dir}default-medium.jpg" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />
         {/if}
        </a><br />
        <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}">{$subcategory.name|escape:'htmlall':'UTF-8'}</a>

Link to comment
Share on other sites

Merci beaucoup ,

 

J'essaies à plusieurs endroits mais ça ne marche pas - Sinon un lien "Voir les autres bijoux de cette catégorie"

 

 {if $category->description}
  <div class="cat_desc">{$category->description}</div>
 {/if}
 {foreach from=$subcategories item=subcat name=subcategories}
<h2>{$subcat.name|upper}</h2>
{if isset($subProducts[$subcat.id_category][0]['name'])}
{include file="$tpl_dir./product-list.tpl" products=$subProducts[$subcat.id_category]}
{else}
<p class="warning">{l s='There are no products in this category.'}</p>
{if $subcategory.id_image}
	   <img src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium')}" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />
	  {else}
	   <img src="{$img_cat_dir}default-medium.jpg" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />
	  {/if}
	 </a><br />
	 <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}">{$subcategory.name|escape:'htmlall':'UTF-8'}</a>
{/if}
{/foreach}
{elseif $category->id}
 <p class="warning">{l s='This category is currently unavailable.'}</p>
{/if}
{/if}

Edited by Miryam68 (see edit history)
Link to comment
Share on other sites

Ok , je suis désolé , et je vous remercie de votre aide , je suis vraiment contente déjà du changement :

 

{*
* 2007-2012 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2012 PrestaShop SA
*  @version  Release: $Revision: 14008 $
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*}
{include file="$tpl_dir./breadcrumb.tpl"}
{include file="$tpl_dir./errors.tpl"}
{if isset($category)}
{if $category->id AND $category->active}
 <h1>
  {strip}
   {$category->name|escape:'htmlall':'UTF-8'}
   {if isset($categoryNameComplement)}
 {$categoryNameComplement|escape:'htmlall':'UTF-8'}
   {/if}
   <span class="category-product-count">
 {include file="$tpl_dir./category-count.tpl"}
   </span>
  {/strip}
 </h1>
 {if $scenes}
  <!-- Scenes -->
  {include file="$tpl_dir./scenes.tpl" scenes=$scenes}
 {else}
  <!-- Category image -->
  {if $category->id_image}
  <div class="align_center">
   <img src="{$link->getCatImageLink($category->link_rewrite, $category->id_image, 'category')}" alt="{$category->name|escape:'htmlall':'UTF-8'}" title="{$category->name|escape:'htmlall':'UTF-8'}" id="categoryImage" width="{$categorySize.width}" height="{$categorySize.height}" />
  </div>
  {/if}
 {/if}
 {if $category->description}
  <div class="cat_desc">{$category->description}</div>
 {/if}
 {foreach from=$subcategories item=subcat name=subcategories}
<h2>{$subcat.name|upper}</h2>
{if isset($subProducts[$subcat.id_category][0]['name'])}
{include file="$tpl_dir./product-list.tpl" products=$subProducts[$subcat.id_category]}
{else}
<p class="warning">{l s='There are no products in this category.'}</p>
{if $subcategory.id_image}
	   <img src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium')}" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />
	  {else}
	   <img src="{$img_cat_dir}default-medium.jpg" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />
	  {/if}
	 </a><br />
	 <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}">{$subcategory.name|escape:'htmlall':'UTF-8'}</a>
{/if}
{/foreach}
{elseif $category->id}
 <p class="warning">{l s='This category is currently unavailable.'}</p>
{/if}
{/if}

Link to comment
Share on other sites

Ok, faisons un essai avec ça :

 

{*
* 2007-2012 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2012 PrestaShop SA
*  @version  Release: $Revision: 14008 $
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*}
{include file="$tpl_dir./breadcrumb.tpl"}
{include file="$tpl_dir./errors.tpl"}
{if isset($category)}
   {if $category->id AND $category->active}
       <h1>
           {strip}
               {$category->name|escape:'htmlall':'UTF-8'}
               {if isset($categoryNameComplement)}
                   {$categoryNameComplement|escape:'htmlall':'UTF-8'}
               {/if}
           {/strip}
       </h1>
       {if $scenes}
           <!-- Scenes -->
           {include file="$tpl_dir./scenes.tpl" scenes=$scenes}
       {else}
           <!-- Category image -->
           {if $category->id_image}
               <div class="align_center">
                   <img src="{$link->getCatImageLink($category->link_rewrite, $category->id_image, 'category')}" alt="{$category->name|escape:'htmlall':'UTF-8'}" title="{$category->name|escape:'htmlall':'UTF-8'}" id="categoryImage" width="{$categorySize.width}" height="{$categorySize.height}" />
               </div>
           {/if}
       {/if}
       {if $category->description}
           <div class="cat_desc">{$category->description}</div>
       {/if}
       {if $products}
           <div class="content_sortPagiBar">
               {include file="$tpl_dir./pagination.tpl"}
               <div class="sortPagiBar clearfix">
                   {include file="./product-sort.tpl"}
                   {include file="./product-compare.tpl"}
                   {include file="./nbr-product-page.tpl"}
               </div>
           </div>

           {include file="./product-list.tpl" products=$products}

           <div class="content_sortPagiBar">
               <div class="sortPagiBar clearfix">
                   {include file="./product-sort.tpl"}
                   {include file="./product-compare.tpl"}
                   {include file="./nbr-product-page.tpl"}
               </div>
               {include file="./pagination.tpl"}
           </div>
       {else}
           <p class="warning">{l s='There are no products in this category.'}</p>
       {/if}
       {foreach from=$subcategories item=subcat name=subcategories}
           <h1>{$subcat.name|upper}</h1>
           {if $subcategory.id_image}
               <div class="align_center">
                   <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}"><img src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium')}" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" /></a>
               </div>
           {/if}
           {if isset($subProducts[$subcat.id_category][0]['name'])}
               {include file="$tpl_dir./product-list.tpl" products=$subProducts[$subcat.id_category]}
               <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}">Voir tous les produits de cette catégorie</a>
           {else}
               <p class="warning">{l s='There are no products in this category.'}</p>
           {/if}
       {/foreach}
   {elseif $category->id}
       <p class="warning">{l s='This category is currently unavailable.'}</p>
   {/if}
{/if}

Link to comment
Share on other sites

Il y a juste un problème en haut avec écrit il n'y a aucun produits dans cette catégorie même so je suprime Warning ...

 

J'ai changé le texte pour éviter les caractère accentué

 

http://www.bijouifique.com/17-colliers

 

Et super le nom est centré , comment lui rajouter le lien également ,

 

<h1>{$subcat.name|upper}</h1> <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)</a>

 

?

Link to comment
Share on other sites

Alors essaye ça :

{*
* 2007-2012 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2012 PrestaShop SA
*  @version  Release: $Revision: 14008 $
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*}
{include file="$tpl_dir./breadcrumb.tpl"}
{include file="$tpl_dir./errors.tpl"}
{if isset($category)}
   {if $category->id AND $category->active}
       <h1>
           {strip}
               {$category->name|escape:'htmlall':'UTF-8'}
               {if isset($categoryNameComplement)}
                   {$categoryNameComplement|escape:'htmlall':'UTF-8'}
               {/if}
           {/strip}
       </h1>
       {if $scenes}
           <!-- Scenes -->
           {include file="$tpl_dir./scenes.tpl" scenes=$scenes}
       {else}
           <!-- Category image -->
           {if $category->id_image}
               <div class="align_center">
                   <img src="{$link->getCatImageLink($category->link_rewrite, $category->id_image, 'category')}" alt="{$category->name|escape:'htmlall':'UTF-8'}" title="{$category->name|escape:'htmlall':'UTF-8'}" id="categoryImage" width="{$categorySize.width}" height="{$categorySize.height}" />
               </div>
           {/if}
       {/if}
       {if $category->description}
           <div class="cat_desc">{$category->description}</div>
       {/if}
       {if $products}
           <div class="content_sortPagiBar">
               {include file="$tpl_dir./pagination.tpl"}
               <div class="sortPagiBar clearfix">
                   {include file="./product-sort.tpl"}
                   {include file="./product-compare.tpl"}
                   {include file="./nbr-product-page.tpl"}
               </div>
           </div>

           {include file="./product-list.tpl" products=$products}

           <div class="content_sortPagiBar">
               <div class="sortPagiBar clearfix">
                   {include file="./product-sort.tpl"}
                   {include file="./product-compare.tpl"}
                   {include file="./nbr-product-page.tpl"}
               </div>
               {include file="./pagination.tpl"}
           </div>
       {/if}
       {foreach from=$subcategories item=subcat name=subcategories}
           <h1><a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}">{$subcat.name|upper}</a></h1>
           {if $subcategory.id_image}
               <div class="align_center">
                   <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}"><img src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium')}" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" /></a>
               </div>
           {/if}
           {if isset($subProducts[$subcat.id_category][0]['name'])}
               {include file="$tpl_dir./product-list.tpl" products=$subProducts[$subcat.id_category]}
               <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}">Voir tous les produits de cette catégorie</a>
           {/if}
       {/foreach}
   {elseif $category->id}
       <p class="warning">{l s='This category is currently unavailable.'}</p>
   {/if}
{/if}

Link to comment
Share on other sites

oups

  1. ID de catégorie manquant

Quand on clique sur les liens

 

Faut peut être reprendre le fichier de base : (si tu en as marre , je vais essayer de trouver c'ets pas grave)

 

{*
* 2007-2012 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2012 PrestaShop SA
*  @version  Release: $Revision: 14008 $
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*}
{include file="$tpl_dir./breadcrumb.tpl"}
{include file="$tpl_dir./errors.tpl"}
{if isset($category)}
{if $category->id AND $category->active}
 <h1>
  {strip}
   {$category->name|escape:'htmlall':'UTF-8'}
   {if isset($categoryNameComplement)}
 {$categoryNameComplement|escape:'htmlall':'UTF-8'}
   {/if}
   <span class="category-product-count">
 {include file="$tpl_dir./category-count.tpl"}
   </span>
  {/strip}
 </h1>
 {if $scenes}
  <!-- Scenes -->
  {include file="$tpl_dir./scenes.tpl" scenes=$scenes}
 {else}
  <!-- Category image -->
  {if $category->id_image}
  <div class="align_center">
   <img src="{$link->getCatImageLink($category->link_rewrite, $category->id_image, 'category')}" alt="{$category->name|escape:'htmlall':'UTF-8'}" title="{$category->name|escape:'htmlall':'UTF-8'}" id="categoryImage" width="{$categorySize.width}" height="{$categorySize.height}" />
  </div>
  {/if}
 {/if}
 {if $category->description}
  <div class="cat_desc">{$category->description}</div>
 {/if}
 {if isset($subcategories)}
 <!-- Subcategories -->
 <div id="subcategories">
  <h3>{l s='Subcategories'}</h3>
  <ul class="inline_list">
  {foreach from=$subcategories item=subcategory}
   <li>
 <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$subcategory.name|escape:'htmlall':'UTF-8'}">
  {if $subcategory.id_image}
   <img src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium')}" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />
  {else}
   <img src="{$img_cat_dir}default-medium.jpg" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />
  {/if}
 </a><br />
 <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}">{$subcategory.name|escape:'htmlall':'UTF-8'}</a>
   </li>
  {/foreach}
  </ul>
  <br class="clear"/>
 </div>
 {/if}
 {if $products}
   {include file="$tpl_dir./product-compare.tpl"}
   {include file="$tpl_dir./product-sort.tpl"}
   {include file="$tpl_dir./product-list.tpl" products=$products}
   {include file="$tpl_dir./product-compare.tpl"}
   {include file="$tpl_dir./pagination.tpl"}
  {elseif !isset($subcategories)}
   <p class="warning">{l s='There are no products in this category.'}</p>
  {/if}
{elseif $category->id}
 <p class="warning">{l s='This category is currently unavailable.'}</p>
{/if}
{/if}

Link to comment
Share on other sites

Exact erreur d'inattention... Essayes ça :

{*
* 2007-2012 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2012 PrestaShop SA
*  @version  Release: $Revision: 14008 $
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*}
{include file="$tpl_dir./breadcrumb.tpl"}
{include file="$tpl_dir./errors.tpl"}
{if isset($category)}
   {if $category->id AND $category->active}
       <h1>
           {strip}
               {$category->name|escape:'htmlall':'UTF-8'}
               {if isset($categoryNameComplement)}
                   {$categoryNameComplement|escape:'htmlall':'UTF-8'}
               {/if}
           {/strip}
       </h1>
       {if $scenes}
           <!-- Scenes -->
           {include file="$tpl_dir./scenes.tpl" scenes=$scenes}
       {else}
           <!-- Category image -->
           {if $category->id_image}
               <div class="align_center">
                   <img src="{$link->getCatImageLink($category->link_rewrite, $category->id_image, 'category')}" alt="{$category->name|escape:'htmlall':'UTF-8'}" title="{$category->name|escape:'htmlall':'UTF-8'}" id="categoryImage" width="{$categorySize.width}" height="{$categorySize.height}" />
               </div>
           {/if}
       {/if}
       {if $category->description}
           <div class="cat_desc">{$category->description}</div>
       {/if}
       {if $products}
           <div class="content_sortPagiBar">
               {include file="$tpl_dir./pagination.tpl"}
               <div class="sortPagiBar clearfix">
                   {include file="./product-sort.tpl"}
                   {include file="./product-compare.tpl"}
                   {include file="./nbr-product-page.tpl"}
               </div>
           </div>

           {include file="./product-list.tpl" products=$products}

           <div class="content_sortPagiBar">
               <div class="sortPagiBar clearfix">
                   {include file="./product-sort.tpl"}
                   {include file="./product-compare.tpl"}
                   {include file="./nbr-product-page.tpl"}
               </div>
               {include file="./pagination.tpl"}
           </div>
       {/if}
       {foreach from=$subcategories item=subcat name=subcategories}
           <h1>{$subcat.name|upper}</h1>
           {if $subcat.id_image}
               <div class="align_center">
                   <a href="{$link->getCategoryLink($subcat.id_category, $subcat.link_rewrite)|escape:'htmlall':'UTF-8'}"><img src="{$link->getCatImageLink($subcat.link_rewrite, $subcat.id_image, 'medium')}" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" /></a>
               </div>
           {/if}
           {if $subcat.description}
               <div class="cat_desc">{$subcat.description}</div>
           {/if}
           {if isset($subProducts[$subcat.id_category][0]['name'])}
               {include file="$tpl_dir./product-list.tpl" products=$subProducts[$subcat.id_category]}
           {/if}
       {/foreach}
   {elseif $category->id}
       <p class="warning">{l s='This category is currently unavailable.'}</p>
   {/if}
{/if}

Link to comment
Share on other sites

Ok, essayes ça :

{*
* 2007-2012 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2012 PrestaShop SA
*  @version  Release: $Revision: 14008 $
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*}
{include file="$tpl_dir./breadcrumb.tpl"}
{include file="$tpl_dir./errors.tpl"}
{if isset($category)}
   {if $category->id AND $category->active}
       <h1>
           {strip}
               {$category->name|escape:'htmlall':'UTF-8'}
               {if isset($categoryNameComplement)}
                   {$categoryNameComplement|escape:'htmlall':'UTF-8'}
               {/if}
           {/strip}
       </h1>
       {if $scenes}
           <!-- Scenes -->
           {include file="$tpl_dir./scenes.tpl" scenes=$scenes}
       {else}
           <!-- Category image -->
           {if $category->id_image}
               <div class="align_center">
                   <img src="{$link->getCatImageLink($category->link_rewrite, $category->id_image, 'category')}" alt="{$category->name|escape:'htmlall':'UTF-8'}" title="{$category->name|escape:'htmlall':'UTF-8'}" id="categoryImage" width="{$categorySize.width}" height="{$categorySize.height}" />
               </div>
           {/if}
       {/if}
       {if $category->description}
           <div class="cat_desc">{$category->description}</div>
       {/if}
       {if $products}
           <div class="content_sortPagiBar">
               {include file="$tpl_dir./pagination.tpl"}
               <div class="sortPagiBar clearfix">
                   {include file="./product-sort.tpl"}
                   {include file="./product-compare.tpl"}
                   {include file="./nbr-product-page.tpl"}
               </div>
           </div>

           {include file="./product-list.tpl" products=$products}

           <div class="content_sortPagiBar">
               <div class="sortPagiBar clearfix">
                   {include file="./product-sort.tpl"}
                   {include file="./product-compare.tpl"}
                   {include file="./nbr-product-page.tpl"}
               </div>
               {include file="./pagination.tpl"}
           </div>
       {/if}
       {if isset($subcategories)}
           {foreach from=$subcategories item=subcat name=subcategories}
               <h1><a href="{$link->getCategoryLink($subcat.id_category, $subcat.link_rewrite)|escape:'htmlall':'UTF-8'}">{$subcat.name|upper}</a></h1>
               {if $subcat.id_image}
                   <div class="align_center">
                       <a href="{$link->getCategoryLink($subcat.id_category, $subcat.link_rewrite)|escape:'htmlall':'UTF-8'}"><img src="{$link->getCatImageLink($subcat.link_rewrite, $subcat.id_image, 'medium')}" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" /></a>
                   </div>
               {/if}
               {if $subcat.description}
                   <div class="cat_desc">{$subcat.description}</div>
               {/if}
               {if isset($subProducts[$subcat.id_category][0]['name'])}
                   {include file="$tpl_dir./product-list.tpl" products=$subProducts[$subcat.id_category]}
               {/if}
           {/foreach}
       {/if}
   {elseif $category->id}
       <p class="warning">{l s='This category is currently unavailable.'}</p>
   {/if}
{/if}

Link to comment
Share on other sites

www/controllers/CategoryController.php

 

<?php
/*
* 2007-2012 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2012 PrestaShop SA
*  @version  Release: $Revision: 16832 $
*  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
class CategoryControllerCore extends FrontController
{
public $php_self = 'category.php';

protected $category;
public function setMedia()
{
 parent::setMedia();
 Tools::addCSS(array(
  _PS_CSS_DIR_.'jquery.cluetip.css' => 'all',
  _THEME_CSS_DIR_.'scenes.css' => 'all',
  _THEME_CSS_DIR_.'category.css' => 'all',
  _THEME_CSS_DIR_.'product_list.css' => 'all'));
 if (Configuration::get('PS_COMPARATOR_MAX_ITEM') > 0)
  Tools::addJS(_THEME_JS_DIR_.'products-comparison.js');
}
public function displayHeader()
{
 parent::displayHeader();
 $this->productSort();
}
public function canonicalRedirection()
{
 // Automatically redirect to the canonical URL if the current in is the right one
 // $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain
 if (Validate::isLoadedObject($this->category) && Configuration::get('PS_CANONICAL_REDIRECT') && strtoupper($_SERVER['REQUEST_METHOD']) == 'GET' && !Tools::getValue('noredirect'))
 {
  $currentURL = preg_replace('/[?&].*$/', '', self::$link->getCategoryLink($this->category));
  if (!preg_match('/^'.Tools::pRegexp($currentURL, '/').'([&?].*)?$/', Tools::getProtocol().$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']))
  {
   header('HTTP/1.0 301 Moved');
   header('Cache-Control: no-cache');
   if (defined('_PS_MODE_DEV_') && _PS_MODE_DEV_)
 die('[Debug] This page has moved<br />Please use the following URL instead: <a href="'.$currentURL.'">'.$currentURL.'</a>');
   Tools::redirectLink($currentURL);
  }
 }
}

public function preProcess()
{
 if ($id_category = (int)Tools::getValue('id_category'))
  $this->category = new Category($id_category, self::$cookie->id_lang);
 if (!Validate::isLoadedObject($this->category))
 {
  header('HTTP/1.1 404 Not Found');
  header('Status: 404 Not Found');
 }
 else
  $this->canonicalRedirection();

 parent::preProcess();
}

public function process()
{
 parent::process();
 if (!($id_category = (int)Tools::getValue('id_category')) OR !Validate::isUnsignedId($id_category))
  $this->errors[] = Tools::displayError('Missing category ID');
 else
 {
  if (!Validate::isLoadedObject($this->category))
   $this->errors[] = Tools::displayError('Category does not exist');
  elseif (!$this->category->checkAccess((int)(self::$cookie->id_customer)))
   $this->errors[] = Tools::displayError('You do not have access to this category.');
  elseif (!$this->category->active)
   self::$smarty->assign('category', $this->category);
  else
  {
   $rewrited_url = self::$link->getCategoryLink((int)$this->category->id, $this->category->link_rewrite);
   /* Scenes  (could be externalised to another controler if you need them */
   self::$smarty->assign('scenes', Scene::getScenes((int)($this->category->id), (int)(self::$cookie->id_lang), true, false));

   /* Scenes images formats */
   if ($sceneImageTypes = ImageType::getImagesTypes('scenes'))
   {
 foreach ($sceneImageTypes as $sceneImageType)
 {
  if ($sceneImageType['name'] == 'thumb_scene')
   $thumbSceneImageType = $sceneImageType;
  elseif ($sceneImageType['name'] == 'large_scene')
   $largeSceneImageType = $sceneImageType;
 }
 self::$smarty->assign('thumbSceneImageType', isset($thumbSceneImageType) ? $thumbSceneImageType : NULL);
 self::$smarty->assign('largeSceneImageType', isset($largeSceneImageType) ? $largeSceneImageType : NULL);
   }
   $this->category->description = nl2br2($this->category->description);
   $subCategories = $this->category->getSubCategories((int)self::$cookie->id_lang);
   self::$smarty->assign('category', $this->category);

   if (isset($subCategories) && !empty($subCategories) && $subCategories)
   {
 self::$smarty->assign('subcategories', $subCategories);
 self::$smarty->assign(array(
  'subcategories_nb_total' => sizeof($subCategories),
  'subcategories_nb_half' => ceil(sizeof($subCategories) / 2)));
   }
   if ($this->category->id != 1)
 $this->productListAssign();
   self::$smarty->assign(array(
 'products' => (isset($this->cat_products) AND $this->cat_products) ? $this->cat_products : NULL,
 'id_category' => (int)($this->category->id),
 'id_category_parent' => (int)($this->category->id_parent),
 'return_category_name' => Tools::safeOutput($this->category->name),
 'path' => Tools::getPath((int)($this->category->id)),
 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
 'categorySize' => Image::getSize('category'),
 'mediumSize' => Image::getSize('medium'),
 'thumbSceneSize' => Image::getSize('thumb_scene'),
 'homeSize' => Image::getSize('home')
   ));

   if (isset(self::$cookie->id_compare))
 self::$smarty->assign('compareProducts', CompareProduct::getCompareProducts((int)self::$cookie->id_compare));
  }
 }
$subProducts = array();
foreach($subCategories as $subCat)
{
$tmp_cat_obj = new Category($subCat['id_category'], self::$cookie->id_lang);
$subProducts[$subCat['id_category']] = $tmp_cat_obj->getProducts(intval(self::$cookie->id_lang), 1, 4, $this->orderBy, $this->orderWay);
}
self::$smarty->assign('subProducts', $subProducts);
 self::$smarty->assign(array(
  'allow_oosp' => (int)(Configuration::get('PS_ORDER_OUT_OF_STOCK')),
  'comparator_max_item' => (int)(Configuration::get('PS_COMPARATOR_MAX_ITEM')),
  'suppliers' => Supplier::getSuppliers()
 ));
}

public function productListAssign()
{
 $hookExecuted = false;
 Module::hookExec('productListAssign', array('nbProducts' => &$this->nbProducts, 'catProducts' => &$this->cat_products, 'hookExecuted' => &$hookExecuted));
 if(!$hookExecuted) // The hook was not executed, standard working
 {
  self::$smarty->assign('categoryNameComplement', '');
  $this->nbProducts = $this->category->getProducts(NULL, NULL, NULL, $this->orderBy, $this->orderWay, true);
  $this->pagination((int)$this->nbProducts); // Pagination must be call after "getProducts"
  $this->cat_products = $this->category->getProducts((int)(self::$cookie->id_lang), (int)($this->p), (int)($this->n), $this->orderBy, $this->orderWay);
 }
 else // Hook executed, use the override
  $this->pagination((int)$this->nbProducts); // Pagination must be call after "getProducts"
 self::$smarty->assign('nb_products', (int)$this->nbProducts);
}
public function displayContent()
{
 parent::displayContent();
 self::$smarty->display(_PS_THEME_DIR_.'category.tpl');
}
}

Link to comment
Share on other sites

Remplace category.tpl par

{*
* 2007-2012 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2012 PrestaShop SA
*  @version  Release: $Revision: 14008 $
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*}
{include file="$tpl_dir./breadcrumb.tpl"}
{include file="$tpl_dir./errors.tpl"}
{if isset($category)}
   {if $category->id AND $category->active}
       <h1>
           {strip}
               {$category->name|escape:'htmlall':'UTF-8'}
               {if isset($categoryNameComplement)}
                   {$categoryNameComplement|escape:'htmlall':'UTF-8'}
               {/if}
           {/strip}
       </h1>
       {if $scenes}
           <!-- Scenes -->
           {include file="$tpl_dir./scenes.tpl" scenes=$scenes}
       {else}
           <!-- Category image -->
           {if $category->id_image}
               <div class="align_center">
                   <img src="{$link->getCatImageLink($category->link_rewrite, $category->id_image, 'category')}" alt="{$category->name|escape:'htmlall':'UTF-8'}" title="{$category->name|escape:'htmlall':'UTF-8'}" id="categoryImage" width="{$categorySize.width}" height="{$categorySize.height}" />
               </div>
           {/if}
       {/if}
       {if $category->description}
           <div class="cat_desc">{$category->description}</div>
       {/if}
       {if $products}
           <div class="content_sortPagiBar">
               {include file="$tpl_dir./pagination.tpl"}
               <div class="sortPagiBar clearfix">
                   {include file="./product-sort.tpl"}
                   {include file="./product-compare.tpl"}
                   {include file="./nbr-product-page.tpl"}
               </div>
           </div>

           {include file="./product-list.tpl" products=$products}

           <div class="content_sortPagiBar">
               <div class="sortPagiBar clearfix">
                   {include file="./product-sort.tpl"}
                   {include file="./product-compare.tpl"}
                   {include file="./nbr-product-page.tpl"}
               </div>
               {include file="./pagination.tpl"}
           </div>
       {/if}
       {if isset($subcategories)}
           {foreach from=$subcategories item=subcat name=subcategories}
               <h1><a href="{$link->getCategoryLink($subcat.id_category, $subcat.link_rewrite)|escape:'htmlall':'UTF-8'}">{$subcat.name|upper}</a></h1>
               {if $subcat.id_image}
                   <div class="align_center">
                       <a href="{$link->getCategoryLink($subcat.id_category, $subcat.link_rewrite)|escape:'htmlall':'UTF-8'}"><img src="{$link->getCatImageLink($subcat.link_rewrite, $subcat.id_image, 'category')}" alt="{$subcat.name|escape:'htmlall':'UTF-8'}" title="{$subcat.name|escape:'htmlall':'UTF-8'}" width="{$categorySize.width}" height="{$categorySize.height}" /></a>
                   </div>
               {/if}
               {if $subcat.description}
                   <div class="cat_desc">{$subcat.description}</div>
               {/if}
               {if isset($subProducts[$subcat.id_category][0]['name'])}
                   {include file="$tpl_dir./product-list.tpl" products=$subProducts[$subcat.id_category]}
               {/if}
           {/foreach}
       {/if}
   {elseif $category->id}
       <p class="warning">{l s='This category is currently unavailable.'}</p>
   {/if}
{/if}

 

Remplace controllers/CategoryController.php par :

<?php
/*
* 2007-2012 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2012 PrestaShop SA
*  @version  Release: $Revision: 16832 $
*  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
class CategoryControllerCore extends FrontController
{
public $php_self = 'category.php';
protected $category;
public function setMedia()
{
 parent::setMedia();
 Tools::addCSS(array(
  _PS_CSS_DIR_.'jquery.cluetip.css' => 'all',
  _THEME_CSS_DIR_.'scenes.css' => 'all',
  _THEME_CSS_DIR_.'category.css' => 'all',
  _THEME_CSS_DIR_.'product_list.css' => 'all')
 );
 if (Configuration::get('PS_COMPARATOR_MAX_ITEM') > 0)
  Tools::addJS(_THEME_JS_DIR_.'products-comparison.js');
}

public function displayHeader()
{
 parent::displayHeader();
 $this->productSort();
}

public function canonicalRedirection()
{
 // Automatically redirect to the canonical URL if the current in is the right one
 // $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain
 if (Validate::isLoadedObject($this->category) && Configuration::get('PS_CANONICAL_REDIRECT') && strtoupper($_SERVER['REQUEST_METHOD']) == 'GET' && !Tools::getValue('noredirect'))
 {
  $currentURL = preg_replace('/[?&].*$/', '', self::$link->getCategoryLink($this->category));
  if (!preg_match('/^'.Tools::pRegexp($currentURL, '/').'([&?].*)?$/', Tools::getProtocol().$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']))
  {
   header('HTTP/1.0 301 Moved');
   header('Cache-Control: no-cache');
   if (defined('_PS_MODE_DEV_') && _PS_MODE_DEV_)
 die('[Debug] This page has moved<br />Please use the following URL instead: <a href="'.$currentURL.'">'.$currentURL.'</a>');
   Tools::redirectLink($currentURL);
  }
 }
}
public function preProcess()
{
 if ($id_category = (int)Tools::getValue('id_category'))
  $this->category = new Category($id_category, self::$cookie->id_lang);
 if (!Validate::isLoadedObject($this->category))
 {
  header('HTTP/1.1 404 Not Found');
  header('Status: 404 Not Found');
 }
 else
  $this->canonicalRedirection();
 parent::preProcess();
}
public function process()
{
 parent::process();

 if (!($id_category = (int)Tools::getValue('id_category')) OR !Validate::isUnsignedId($id_category))
  $this->errors[] = Tools::displayError('Missing category ID');
 else
 {
  if (!Validate::isLoadedObject($this->category))
   $this->errors[] = Tools::displayError('Category does not exist');
  elseif (!$this->category->checkAccess((int)(self::$cookie->id_customer)))
   $this->errors[] = Tools::displayError('You do not have access to this category.');
  elseif (!$this->category->active)
   self::$smarty->assign('category', $this->category);
  else
  {
   $rewrited_url = self::$link->getCategoryLink((int)$this->category->id, $this->category->link_rewrite);
   /* Scenes  (could be externalised to another controler if you need them */
   self::$smarty->assign('scenes', Scene::getScenes((int)($this->category->id), (int)(self::$cookie->id_lang), true, false));
   /* Scenes images formats */
   if ($sceneImageTypes = ImageType::getImagesTypes('scenes'))
   {
 foreach ($sceneImageTypes as $sceneImageType)
 {
  if ($sceneImageType['name'] == 'thumb_scene')
   $thumbSceneImageType = $sceneImageType;
  elseif ($sceneImageType['name'] == 'large_scene')
   $largeSceneImageType = $sceneImageType;
 }
 self::$smarty->assign('thumbSceneImageType', isset($thumbSceneImageType) ? $thumbSceneImageType : NULL);
 self::$smarty->assign('largeSceneImageType', isset($largeSceneImageType) ? $largeSceneImageType : NULL);
   }
   $this->category->description = nl2br2($this->category->description);
   $subCategories = $this->category->getSubCategories((int)self::$cookie->id_lang);
   self::$smarty->assign('category', $this->category);
   if (isset($subCategories) && !empty($subCategories) && $subCategories)
   {
 $subProducts = array();
 foreach($subCategories as $subCat)
 {
  $tmp_cat_obj = new Category($subCat['id_category'], self::$cookie->id_lang);
  $subProducts[$subCat['id_category']] = $tmp_cat_obj->getProducts(intval(self::$cookie->id_lang), 1, 4, $this->orderBy, $this->orderWay);
 }
 self::$smarty->assign(array(
  'subcategories' => $subCategories,
  'subcategories_nb_total' => sizeof($subCategories),
  'subcategories_nb_half' => ceil(sizeof($subCategories) / 2),
  'subProducts' => $subProducts
 ));
   }
   if ($this->category->id != 1)
 $this->productListAssign();

   self::$smarty->assign(array(
 'products' => (isset($this->cat_products) AND $this->cat_products) ? $this->cat_products : NULL,
 'id_category' => (int)($this->category->id),
 'id_category_parent' => (int)($this->category->id_parent),
 'return_category_name' => Tools::safeOutput($this->category->name),
 'path' => Tools::getPath((int)($this->category->id)),
 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
 'categorySize' => Image::getSize('category'),
 'mediumSize' => Image::getSize('medium'),
 'thumbSceneSize' => Image::getSize('thumb_scene'),
 'homeSize' => Image::getSize('home')
   ));
   if (isset(self::$cookie->id_compare))
 self::$smarty->assign('compareProducts', CompareProduct::getCompareProducts((int)self::$cookie->id_compare));
  }
 }
 self::$smarty->assign(array(
  'allow_oosp' => (int)(Configuration::get('PS_ORDER_OUT_OF_STOCK')),
  'comparator_max_item' => (int)(Configuration::get('PS_COMPARATOR_MAX_ITEM')),
  'suppliers' => Supplier::getSuppliers()
 ));
}
public function productListAssign()
{
 $hookExecuted = false;
 Module::hookExec('productListAssign', array('nbProducts' => &$this->nbProducts, 'catProducts' => &$this->cat_products, 'hookExecuted' => &$hookExecuted));
 if(!$hookExecuted) // The hook was not executed, standard working
 {
  self::$smarty->assign('categoryNameComplement', '');
  $this->nbProducts = $this->category->getProducts(NULL, NULL, NULL, $this->orderBy, $this->orderWay, true);
  $this->pagination((int)$this->nbProducts); // Pagination must be call after "getProducts"
  $this->cat_products = $this->category->getProducts((int)(self::$cookie->id_lang), (int)($this->p), (int)($this->n), $this->orderBy, $this->orderWay);
 }
 else // Hook executed, use the override
  $this->pagination((int)$this->nbProducts); // Pagination must be call after "getProducts"

 self::$smarty->assign('nb_products', (int)$this->nbProducts);
}

public function displayContent()
{
 parent::displayContent();
 self::$smarty->display(_PS_THEME_DIR_.'category.tpl');
}
}

Link to comment
Share on other sites

J'ai remis comme avant , c'est dommage parce que tout fonctionne sauf le lien

 

^--- oui

 

Il ya un problème avec la page produits chaque fois qu'on fait ces modifications , c'est dommage acr l'apparence est super , mais quand on clique sur une sous-catégories , y'a une partie de la page en blanc, à chaque fois , c'est bizarre

Link to comment
Share on other sites

En dehors de ton thème, tu as ajouté des modules ?

Si l'auteur de ton thème propose une version 1.51 et que les auteurs des modules que tu as ajoutés proposent des versions pour 1.51 autant faire la mise à jour.

Sinon tu peux faire la mise à jour puis adapter le thème par défaut de la version 1.5.1 pour qu'il reprenne les éléments de ton thème actuel.

Link to comment
Share on other sites

Non l'auteur de mon thème ne propose pas le thème en 1.5.1 et oui j'ai ajouter des modules ,et énormément modifié mon thème au niveau du design

 

Ca me fait un peu peur de faire la mise à jour , surtout que je veux pas mettre la boutique en maintenance , je suis en plein dans le référencement , la publicité ect :S

Link to comment
Share on other sites

  • 4 weeks later...

Bonjour,

 

I'm sorry to write in english but my french is really terrible and I need to solve this problem. I use presta 1.5.1 and I need to display the parent category before the product title in product-list.tpl.

 

I used this: <h1>$product.category|escape:'htmlall':'UTF-8'}</h1> but it displays like this "name-surname" and I need "Name Surname". So I understood I need $category->name but it doesn't show.

 

How do I load this $category->name data?

 

Thank you, merci!

 

Luca

Edited by luca.giaicheca (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...