Jump to content

Override CategoryController


Recommended Posts

Bonjour à vous,

 

Je souhaiterais faire un override du CategoryController pour faire afficher la catégories parente.

 

Car une personne avant moi à mis ça directement dans le CategoryController :

public function process()
  {
    global $cookie;
    $parent = new Category(Tools::getValue('id_category'), intval($cookie->id_lang));
    $listing=$parent->getParentsCategories($cookie->id_lang);
    foreach ($listing as $list)
     {
      if($list['level_depth']==2)
  	 {
  	  self::$smarty->assign('parent',$list['name']);
  	  break;
  	 }
     }
     $parent2 = new Category(Tools::getValue('id_category'), intval($cookie->id_lang));
    $listing2=$parent2->getParentsCategories($cookie->id_lang);
    foreach ($listing2 as $list2)
     {
      if($list2['level_depth']==3)
  	 {
  	  self::$smarty->assign('parent2',$list2['name']);
  	  break;
  	 }
     }
     $parent3 = new Category(Tools::getValue('id_category'), intval($cookie->id_lang));
    $listing3=$parent3->getParentsCategories($cookie->id_lang);
    foreach ($listing3 as $list3)
     {
      if($list3['level_depth']==2)
  	 {
  	  self::$smarty->assign('parent3',$list3['link_rewrite']);
  	  break;
  	 }
     }
     $parent4 = new Category(Tools::getValue('id_category'), intval($cookie->id_lang));
    $listing4=$parent4->getParentsCategories($cookie->id_lang);
    foreach ($listing4 as $list4)
     {
      if($list4['level_depth']==3)
  	 {
  	  self::$smarty->assign('parent4',$list4['link_rewrite']);
  	  break;
  	 }
     }
     $parent5 = new Category(Tools::getValue('id_category'), intval($cookie->id_lang));
    $listing5=$parent5->getParentsCategories($cookie->id_lang);
    foreach ($listing5 as $list5)
     {
      if($list5['level_depth']==2)
  	 {
  	  self::$smarty->assign('parent5',$list5['id_category']);
  	  break;
  	 }
     }
     $parent6 = new Category(Tools::getValue('id_category'), intval($cookie->id_lang));
    $listing6=$parent6->getParentsCategories($cookie->id_lang);
    foreach ($listing6 as $list6)
     {
      if($list6['level_depth']==3)
  	 {
  	  self::$smarty->assign('parent6',$list6['id_category']);
  	  break;
  	 }
     }
  }

J'aimerais bien entendu faire ça plus proprement en le mettant dans un override, mais la class process n'existe pas de base. 

 

Comment faire ?

 

Merci a vous.

Link to comment
Share on other sites

salut,

<?php
/*
* 2007-2016 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-2016 PrestaShop SA
*  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/

class CategoryController extends CategoryControllerCore
{
... ton code...
}

cdt

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...