Magento : Affichage du logo de la catégorie courante

http://www.soft-alternative.com/usr/images/tutoriaux/magento-affichage-du-logo-de-la-categorie-courante/magento-affichage-du-logo-de-la-categorie-courante.jpg

Présentation

Magento permet d'attribuer un logo dans l'entête de chaque boutique. Ce logo est commun à l'ensemble des pages de la boutique. Il est possible par l'intermédiaire du thème de personnaliser l'affichage du logo en fonction de la catégorie courante (exemple le logo de chaque thème principal de la boutique).

Procédure

  1. Editer le fichier "header.phtml" dans votre template courant ("app/design/frontend/{interface}/{theme}/page/html/header.phtml").

    Remplacer la syntaxe :
    (...)
    
    <?php if ($this->getIsHomePage()): ?>
    <h1 class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a></h1>
    <?php else:?>
    <a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a>
    <?php endif; ?>
    
    (...)
    Par :
    (...)
    
    <?php if ($this->getIsHomePage()):?>
    <h1 class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a></h1>
    <?php else:?>
    <? $_currentCategory = Mage::registry('current_category'); if (isset($_currentCategory)): if ($_currentCategory->getImageUrl()): ?>
    <a href="<?php echo $_currentCategory->getUrl(); ?>" title="<?php echo $_currentCategory->getName(); ?>" class="logo"><strong><?php echo $_currentCategory->getName(); ?></strong><img src="<?php echo $_currentCategory->getImageUrl(); ?>" alt="<?php echo $_currentCategory->getName(); ?>" /></a>
    <?php else: ?>
    <a href="<?php echo $this->getUrl(''); ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a>
    <?php endif; endif;  endif; ?>
    
    (...)
  2. Se connecter à l'interface d'administration (exemple : www.maboutique.com/index.php/admin/).

  3. Cliquer sur l'option "Gestion des catégories" dans le menu "Catalogue". Pour accéder à l'édition des catégories.

  4. Sélectionner une catégorie et lui associer une image dans le champ "image". Puis valider la modification avec le bouton "Sauvegarder".

    REMARQUE :
    • Il est possible d'affecter une image les différentes catégories à configurer.
  5. Le logo sera maintenant affiché en fonction de la catégorie courante. Les autres pages (CMS, core...) afficheront le logo par défaut affecté à la boutique.