Omaley Posted January 18, 2016 Share Posted January 18, 2016 Bonjour, j'ai creer un module qui doit modifier la methode renderForm de AdminManufacturerController dans mon backoffice pour rajouter un champ. Sauf que l'override que j'ai créer a cette effet ne s'applique pas. Cependant le meme code hors de mon module dans le dossier de base /override fonctionne. J'en deduis donc que j'ai manquer quelque chose. Voici mon code : MonModule: <?php if (!defined('_PS_VERSION_')) exit; class MyModule extends Module { public function __construct() { $this->name = 'mymodule'; $this->tab = 'front_office_features'; $this->version = '1.0'; $this->author = 'PA'; $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.5', 'max' => '1.6'); $this->dependencies = array('blockcart'); parent::__construct(); $this->displayName = $this->l('My module'); $this->description = $this->l('Description of my module.'); $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); if (!Configuration::get('MYMODULE_NAME')) $this->warning = $this->l('No name provided'); } public function install() { if (!parent::install() || !$this->registerHook('testSoluka') ) return false; } public function uninstall() { if (!parent::uninstall() || !Configuration::deleteByName('MYMODULE_NAME') ) return false; return true; } public function hookTestSoluka ($params) { return $this->display(__FILE__, 'mymodule.tpl'); } } ?> Mon AdminManfacturerController dans monModule/override/controller/admin class AdminManufacturersController extends AdminManufacturersControllerCore { public $bootstrap = true ; /** @var array countries list */ protected $countries_array = array(); public function renderForm() { if (!($manufacturer = $this->loadObject(true))) { return; } $image = _PS_MANU_IMG_DIR_.$manufacturer->id.'.jpg'; $image_url = ImageManager::thumbnail($image, $this->table.'_'.(int)$manufacturer->id.'.'.$this->imageType, 350, $this->imageType, true, true); $image_size = file_exists($image) ? filesize($image) / 1000 : false; parent::renderForm(); $this->fields_form = array( 'tinymce' => true, 'legend' => array( 'title' => $this->l('Manufacturers'), 'icon' => 'icon-certificate' ), 'input' => array( array( 'type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'col' => 4, 'required' => true, 'hint' => $this->l('Invalid characters:').' <>;=#{}' ), array( 'type' => 'textarea', 'label' => $this->l('Short description'), 'name' => 'short_description', 'lang' => true, 'cols' => 60, 'rows' => 10, 'autoload_rte' => 'rte', //Enable TinyMCE editor for short description 'col' => 6, 'hint' => $this->l('Invalid characters:').' <>;=#{}' ), array( 'type' => 'textarea', 'label' => $this->l('Description5555555555555'), 'name' => 'description', 'lang' => true, 'cols' => 60, 'rows' => 10, 'col' => 6, 'autoload_rte' => 'rte', //Enable TinyMCE editor for description 'hint' => $this->l('Invalid characters:').' <>;=#{}' ), array( 'type' => 'file', 'label' => $this->l('Logo'), 'name' => 'logo', 'image' => $image_url ? $image_url : false, 'size' => $image_size, 'display_image' => true, 'col' => 6, 'hint' => $this->l('Upload a manufacturer logo from your computer.') ), array( 'type' => 'text', 'label' => $this->l('Meta title555555555555'), 'name' => 'meta_title', 'lang' => true, 'col' => 4, 'hint' => $this->l('Forbidden characters:').' <>;=#{}' ), array( 'type' => 'text', 'label' => $this->l('Meta description555555555555'), 'name' => 'meta_description', 'lang' => true, 'col' => 6, 'hint' => $this->l('Forbidden characters:').' <>;=#{}' ), array( 'type' => 'tags', 'label' => $this->l('Meta keywords'), 'name' => 'meta_keywords', 'lang' => true, 'col' => 6, 'hint' => array( $this->l('Forbidden characters:').' <>;=#{}', $this->l('To add "tags," click inside the field, write something, and then press "Enter."') ) ), array( 'type' => 'switch', 'label' => $this->l('Enable'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ) ) ) ); if (!($manufacturer = $this->loadObject(true))) { return; } if (Shop::isFeatureActive()) { $this->fields_form['input'][] = array( 'type' => 'shop', 'label' => $this->l('Shop association'), 'name' => 'checkBoxShopAsso', ); } $this->fields_form['submit'] = array( 'title' => $this->l('Save') ); foreach ($this->_languages as $language) { $this->fields_value['short_description_'.$language['id_lang']] = htmlentities(stripslashes($this->getFieldValue( $manufacturer, 'short_description', $language['id_lang'] )), ENT_COMPAT, 'UTF-8'); $this->fields_value['description_'.$language['id_lang']] = htmlentities(stripslashes($this->getFieldValue( $manufacturer, 'description', $language['id_lang'] )), ENT_COMPAT, 'UTF-8'); } return AdminController::renderForm(); } Link to comment Share on other sites More sharing options...
coeos.pro Posted January 18, 2016 Share Posted January 18, 2016 1- le fichier est bien dans le dossier override ? 2- avez vous essayez de supprimer le fichier cache/class_index.php ? Link to comment Share on other sites More sharing options...
Omaley Posted January 18, 2016 Author Share Posted January 18, 2016 Mon fichier se trouve bien dans monModule/override/controller/admin Si vous parlez du dossier racine/override/controllers/admin, c'est que je souhaite faire mon override uniquement dans mon module et nulle part ailleur. Et supprimer le cache ne change rien du tout. Link to comment Share on other sites More sharing options...
coeos.pro Posted January 18, 2016 Share Posted January 18, 2016 Mon fichier se trouve bien dans monModule/override/controller/adminc'est bien monModule/override/controllers/admin ? Si vous parlez du dossier racine/override/controllers/admin, c'est que je souhaite faire mon override uniquement dans mon module et nulle part ailleur. je ne comprend pas, vous voulez avoir un override dans votre module et uniquement dans votre module ? il ne pourra pas être pris en compte par votre boutique. Link to comment Share on other sites More sharing options...
Omaley Posted January 19, 2016 Author Share Posted January 19, 2016 (edited) J'ai reussi a mettre mon override dans mon module, cela marche. Edited February 2, 2016 by Omaley (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