Jump to content
Beezkit

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.

Share this post


Link to post
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 license@prestashop.com 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 <contact@prestashop.com>
*  @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

Share this post


Link to post
Share on other sites

Merci pour votre réponse mais si je le met dans override/controller/front et que je fait mon CategoryController.php ça ne marche pas.

Share this post


Link to post
Share on other sites

 

Manipulating the override code manually

Modules and themes may add an override to a default behavior, and PrestaShop takes care of reseting the /cache/class_index.php file.

But sometimes you need to add that overriding code yourself, manually uploading the file to your server. In that case, you need to trigger the regeneration of the /cache/class_index.php file yourself. This is done simply by deleting the file: if PrestaShop cannot find the file, it will regenerate it, taking all the overrides into account.

It is the same when manually removing an override: in order to reinstate the default behavior, you must delete the /cache/class_index.php file.

 

Share this post


Link to post
Share on other sites

Ah bon sang le class_index je l'oublie à chaque fois.

 

Merci à tous

Share this post


Link to post
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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More