aide prestashop PhenixSuite Help
    • Catégories
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes
    • Recherche
    • S'inscrire
    • Se connecter

    Override AdminCustomersController [RÉSOLU]

    Planifier Épinglé Verrouillé Déplacé Bugs & Améliorations
    11 Messages 2 Publieurs 725 Vues 2 Watching
    Charger plus de messages
    • Du plus ancien au plus récent
    • Du plus récent au plus ancien
    • Les plus votés
    Répondre
    • Répondre à l'aide d'un nouveau sujet
    Se connecter pour répondre
    Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
    • Olivier75009O Hors-ligne
      Olivier75009
      dernière édition par Olivier75009

      Bonjour,

      avant de passer à PhenixSuite, nous étions en 1.6.1.24 et avions un override (toujours effectif) d'AdminCustomersController (ajout de champs phone, postcode,...). Désormais il existe des options dans ce controller pour ajouter diverses champs (Siret, Ape,...). Il existe donc des configurations dans la table ps_configuration (PS_COLUMNS_CUSTOMER_x) avec les indications des modifications (ex: "firstname":{"selected":1,"title":"Pr\u00e9nom"}). Mais comment et d'où sont générées ces config' ?

      Merci d'avance.

      www.rituel-manucure.com

      1 réponse Dernière réponse Répondre Citer 0
      • eoliaE Hors-ligne
        eolia
        dernière édition par

        Bonjour,
        Vous avez une icone engrenage en haut à droite de la liste
        columns.gif

        Créateur de PhenixSuite. Pour plus d'infos : https://eoliashop.com

        1 réponse Dernière réponse Répondre Citer 0
        • Olivier75009O Hors-ligne
          Olivier75009
          dernière édition par Olivier75009

          Oui, merci, j'avais bien compris ça. Ce n'était pas le sens de ma question. Au cas où je voudrais y ajouter des champs (override select, left join pour avoir le numéro de tèl, le code postal...) et ajout dans la fields_list (en gardant le "if") + ajout dans $available, je n'ai pas la traduction (les boutons apparaissent comme choix, mais une fois ajoutés il n'y a pas de titre - petits carrés verts).

          Édith : override de la fonction __construct

          www.rituel-manucure.com

          eoliaE 1 réponse Dernière réponse Répondre Citer 0
          • eoliaE Hors-ligne
            eolia @Olivier75009
            dernière édition par

            Une fois votre override installée, réinitialisez le choix des colonnes pour recharger l'ensemble.
            Si votre code est conforme, les traductions doivent apparaitre.

            Créateur de PhenixSuite. Pour plus d'infos : https://eoliashop.com

            1 réponse Dernière réponse Répondre Citer 0
            • Olivier75009O Hors-ligne
              Olivier75009
              dernière édition par

              Merci, m'en vais tester tout ça 😉

              www.rituel-manucure.com

              1 réponse Dernière réponse Répondre Citer 0
              • Olivier75009O Hors-ligne
                Olivier75009
                dernière édition par Olivier75009

                Alors en testant :
                ajout $available -> 'phone' => array('selected' => 0, 'title' => $this->l('Telephone')),
                ajout dans la boucle foreach (columns) ->
                if($key == 'phone') {
                $this->fields_list['phone'] = array(
                'title' => $column['title'],
                );
                }

                mes colonnes s'affichent bien avec les résultats, mais les titres sont vides (ainsi que dans les boutons séléctionnés, les titres sont présents si non activés). Dans la BDD (PS_COLUMNS_CUSTOMER_x) j'ai "phone":{"selected":1}, sans l'ajout du titre.
                Capture d’écran 2023-11-17 à 13.46.02.png
                Capture d’écran 2023-11-17 à 13.46.45.png

                www.rituel-manucure.com

                1 réponse Dernière réponse Répondre Citer 0
                • eoliaE Hors-ligne
                  eolia
                  dernière édition par

                  Vous pourriez m'envoyer votre override, il y a un truc qui m'échappe^^

                  Créateur de PhenixSuite. Pour plus d'infos : https://eoliashop.com

                  1 réponse Dernière réponse Répondre Citer 0
                  • Olivier75009O Hors-ligne
                    Olivier75009
                    dernière édition par Olivier75009

                    <?php
                    class AdminCustomersController extends AdminCustomersControllerCore
                    {
                    
                    
                    	/*
                    	* module: alinkmodadminpanels
                    	* date: 2023-11-17 07:51:35
                    	* version: 0.1
                    	*/
                        public function __construct()
                        {
                            parent::__construct();
                    
                            $this->shopLinkType = (
                                Shop::isFeatureActive()
                                && !$this->context->shop->getGroup()->share_customer
                                && (Shop::getContext() != Shop::CONTEXT_SHOP) ?
                                'shop' :
                                false
                            );
                    
                            $this->_select = '
                            a.ape, a.id_risk, a.id_default_group, a.siret,
                            a.birthday, a.note, a.date_add, gl.name as title, (
                                SELECT SUM(total_paid_real / conversion_rate)
                                FROM '._DB_PREFIX_.'orders o
                                WHERE o.id_customer = a.id_customer
                                '.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
                                AND o.valid = 1
                            ) as total_spent, (
                                SELECT c.date_add FROM '._DB_PREFIX_.'guest g
                                LEFT JOIN '._DB_PREFIX_.'connections c
                                    ON(c.id_guest = g.id_guest)
                                WHERE g.id_customer = a.id_customer
                                ORDER BY c.date_add DESC
                                LIMIT 1
                            ) as connect';
                    
                            $this->_join = '
                                LEFT JOIN '._DB_PREFIX_.'gender_lang gl
                                    ON(a.id_gender = gl.id_gender
                                    AND gl.id_lang = '.(int)$this->context->language->id.')
                                LEFT JOIN (
                                    SELECT MAX(id_address) as last_add, id_customer
                                    FROM '._DB_PREFIX_.'address
                                    GROUP BY id_customer
                                ) last ON last.id_customer = a.id_customer
                                LEFT JOIN (
                                    SELECT city, phone, phone_mobile, postcode, id_address
                                    FROM '._DB_PREFIX_.'address
                                ) adr ON adr.id_address = last.last_add
                                    ';
                            $this->_use_found_rows = false;
                    
                            // Check if we can add a customer
                            if(Shop::isFeatureActive()
                                && (Shop::getContext() == Shop::CONTEXT_ALL || Shop::getContext() == Shop::CONTEXT_GROUP)
                            ) {
                                $this->can_add_customer = false;
                            }
                    
                            $titles_array = array();
                            $genders = Gender::getGenders($this->context->language->id);
                            foreach($genders as $gender) {
                                $titles_array[$gender->id_gender] = $gender->name;
                            }
                    
                            $columns_key = 'PS_COLUMNS_CUSTOMER_'.(int)$this->context->employee->id;
                            $default_selected = array(
                                'title'         => array('selected' => 1, 'title' => $this->l('Social title')),
                                'firstname'     => array('selected' => 1, 'title' => $this->l('First name')),
                                'lastname'      => array('selected' => 1, 'title' => $this->l('Last name')),
                                'email'         => array('selected' => 1, 'title' => $this->l('Email address')),
                                'total_spent'   => array('selected' => 1, 'title' => $this->l('Sales')),
                                'active'        => array('selected' => 1, 'title' => $this->l('Enabled')),
                                'newsletter'    => array('selected' => 1, 'title' => $this->l('Newsletter')),
                                'optin'         => array('selected' => 1, 'title' => $this->l('Opt-in')),
                                'date_add'      => array('selected' => 1, 'title' => $this->l('Registration')),
                                'connect'       => array('selected' => 1, 'title' => $this->l('Last visit')),
                            );
                            $available = array(
                                'phone'         => array('selected' => 0, 'title' => $this->l('Telephone')),
                                'phone_mobile'  => array('selected' => 0, 'title' => $this->l('Mobile')),
                                'city'          => array('selected' => 0, 'title' => $this->l('Ville')),
                                'postcode'      => array('selected' => 0, 'title' => $this->l('Postcode')),
                                'id_risk'       => array('selected' => 0, 'title' => $this->l('Risk')),
                                'siret'         => array('selected' => 0, 'title' => $this->l('Siret')),
                                'ape'           => array('selected' => 0, 'title' => $this->l('APE')),
                                'birthday'      => array('selected' => 0, 'title' => $this->l('Birthday')),
                                'note'          => array('selected' => 0, 'title' => $this->l('Note')),
                            );
                            if(Configuration::get('PS_B2B_ENABLE')) {
                                $available['company'] = array('selected' => 0, 'title' => $this->l('Company'));
                            }
                            
                            if(Group::isFeatureActive()) {
                                $available['id_default_group'] = array('selected' => 0, 'title' => $this->l('Group'));
                            }
                            $defaults = array_merge($default_selected, $available);
                    
                            if(Tools::isSubmit('resetColumns'.$this->table) || !Configuration::get($columns_key)) {
                                Configuration::updateValue($columns_key, json_encode($defaults));
                                $this->processResetFilters();
                                $this->redirect_after = $this->currentLink.'&conf=4';
                            }
                            if(Tools::isSubmit('submitColumns'.$this->table)) {
                                $selected_columns = Tools::getValue('columns'.$this->table);
                                $choice = explode(',', $selected_columns);
                                if(is_array($choice) && !empty($choice[0])) {
                                    $columns = array();
                                    foreach($choice as $field) {
                                        $this->columns[$field] = $defaults[$field];
                                        $this->columns[$field]['selected'] = 1;
                                    }
                                    foreach($defaults as $key => $default) {
                                        if(!isset($this->columns[$key])) {
                                            $this->columns[$key] = $default;
                                            $this->columns[$key]['selected'] = 0;
                                        }
                                    }
                                    Configuration::updateValue($columns_key, json_encode($this->columns));
                                    $this->processResetFilters();
                                    $this->redirect_after = $this->currentLink.'&conf=4';
                                }
                                else {
                                    $this->columns = json_decode(Configuration::get($columns_key), 1);
                                }
                            }
                            else {
                                $this->columns = json_decode(Configuration::get($columns_key), 1);
                            }
                            foreach($defaults as $key => $default) {
                                if(!isset($this->columns[$key])) {
                                    $this->columns[$key] = $default;
                                }
                            }
                            $this->fields_list = array();
                            $this->fields_list['id_customer'] = array(
                                'title' => $this->l('ID'),
                                'align' => 'text-center',
                                'class' => 'fixed-width-sm'
                            );
                            foreach($this->columns as $key => $column) {
                                if($column['selected']) {
                                    if($key == 'title') {
                                        $this->fields_list['title'] = array(
                                            'title'         => $column['title'],
                                            'filter_key'    => 'a!id_gender',
                                            'type'          => 'select',
                                            'list'          => $titles_array,
                                            'filter_type'   => 'int',
                                            'order_key'     => 'gl!name'
                                        );
                                    }
                                    if($key == 'firstname') {
                                        $this->fields_list['firstname'] = array(
                                            'title'         => $column['title'],
                                            'filter_key'    => 'a!firstname',
                                        );
                                    }
                                    if($key == 'lastname') {
                                        $this->fields_list['lastname'] = array(
                                            'title'         => $column['title'],
                                            'filter_key'    => 'a!lastname',
                                        );
                                    }
                                    if($key == 'email') {
                                        $this->fields_list['email'] = array(
                                            'title'         => $column['title'],
                                            'filter_key'    => 'a!email',
                                        );
                                    }
                                    if($key == 'phone') {
                                        $this->fields_list['phone'] = array(
                                            'title'         => $this->l('Téléphone'),
                                        );
                                    }
                                    if($key == 'phone_mobile') {
                                        $this->fields_list['phone_mobile'] = array(
                                            'title'         => $this->l('Mobile'),
                                        );
                                    }
                                    if($key == 'city') {
                                        $this->fields_list['city'] = array(
                                            'title'         => $this->l('Ville'),
                                        );
                                    }
                                    if($key == 'postcode') {
                                        $this->fields_list['postcode'] = array(
                                            'title'         => $this->l('Code postal'),
                                        );
                                    }
                                    if($key == 'company') {
                                        $this->fields_list['company'] = array(
                                            'title'         => $column['title'],
                                            'filter_key'    => 'a!company',
                                        );
                                    }
                                    if($key == 'total_spent') {
                                        $this->fields_list['total_spent'] = array(
                                            'title'         => $column['title'],
                                            'type'          => 'price',
                                            'search'        => false,
                                            'havingFilter'  => true,
                                            'align'         => 'text-right',
                                            'badge_success' => true
                                        );
                                    }
                                    if($key == 'active') {
                                        $this->fields_list['active'] = array(
                                            'title'         => $column['title'],
                                            'align'         => 'text-center',
                                            'active'        => 'status',
                                            'type'          => 'bool',
                                            'filter_key'    => 'a!active'
                                        );
                                    }
                                    if($key == 'newsletter') {
                                        $this->fields_list['newsletter'] = array(
                                            'title'         => $column['title'],
                                            'align'         => 'text-center',
                                            'type'          => 'bool',
                                            'callback'      => 'printNewsIcon'
                                        );
                                    }
                                    if($key == 'optin') {
                                        $this->fields_list['optin'] = array(
                                            'title'         => $column['title'],
                                            'align'         => 'text-center',
                                            'type'          => 'bool',
                                            'callback'      => 'printOptinIcon'
                                        );
                                    }
                                    if($key == 'date_add') {
                                        $this->fields_list['date_add'] = array(
                                            'title'         => $column['title'],
                                            'type'          => 'date',
                                        );
                                    }
                                    if($key == 'connect') {
                                        $this->fields_list['connect'] = array(
                                            'title'         => $column['title'],
                                            'type'          => 'datetime',
                                        );
                                    }
                                    if($key == 'id_risk') {
                                        $risks = Risk::getRisks((int)$this->context->language->id);
                                        $risks_array = array();
                                        foreach($risks as $risk) {
                                            $risks_array[$risk->id_risk] = $risk->name;
                                        }
                                        $this->fields_list['id_risk'] = array(
                                            'title'         => $column['title'],
                                            'type'          => 'select',
                                            'list'          => $risks_array,
                                            'filter_type'   => 'int',
                                            'filter_key'    => 'a!id_risk',
                                            'callback'      => 'displayRisk'
                                        );
                                    }
                                    if($key == 'siret') {
                                        $this->fields_list['siret'] = array(
                                            'title'         => $column['title'],
                                            'type'          => 'text',
                                        );
                                    }
                                    if($key == 'ape') {
                                        $this->fields_list['ape'] = array(
                                            'title'         => $column['title'],
                                            'type'          => 'text',
                                        );
                                    }
                                    if($key == 'birthday') {
                                        $this->fields_list['connect'] = array(
                                            'title'         => $column['title'],
                                            'type'          => 'date',
                                        );
                                    }
                                    if($key == 'note') {
                                        $this->fields_list['note'] = array(
                                            'title'         => $column['title'],
                                            'type'          => 'text',
                                        );
                                    }
                                    if($key == 'id_default_group') {
                                        $groups = Group::getGroups((int)$this->context->language->id, false, true);
                                        $groups_array = array();
                                        foreach($groups as $group) {
                                            $groups_array[$group['id_group']] = $group['name'];
                                        }
                                        $this->fields_list['id_default_group'] = array(
                                            'title'         => $column['title'],
                                            'type'          => 'select',
                                            'list'          => $groups_array,
                                            'filter_type'   => 'int',
                                            'filter_key'    => 'a!id_default_group',
                                            'callback'      => 'displayGroup'
                                        );
                                    }
                                }
                            }
                    
                            self::$meaning_status = array(
                                'open' => $this->l('Open'),
                                'closed' => $this->l('Closed'),
                                'pending1' => $this->l('Pending 1'),
                                'pending2' => $this->l('Pending 2')
                            );
                        }
                    }
                    

                    Édith : j'ai modifié les titres des fields_list pour les champs ajoutés par rapport à la dernière image (le titre est vide pour la colonne, j'avais laissé $column['title']).

                    www.rituel-manucure.com

                    1 réponse Dernière réponse Répondre Citer 0
                    • Olivier75009O Hors-ligne
                      Olivier75009
                      dernière édition par

                      J'ai d($defaults) après array_merge et il m'a pourtant bien sorti les clés et valeurs "title", mais updateValue n'a pas inclus les titres pour mes ajouts. Uniquement les "selected". (Même après avoir supprimer l'entrée dans ps_config).

                      www.rituel-manucure.com

                      1 réponse Dernière réponse Répondre Citer 0
                      • eoliaE Hors-ligne
                        eolia
                        dernière édition par

                        Vous faites l'override d'un constructeur donc vous ne pouvez pas appeler parent::__construct() il faut directement appeler l'AdminController.
                        Ci-joint le fichier complet de l'override 😉
                        AdminCustomersController.php

                        Créateur de PhenixSuite. Pour plus d'infos : https://eoliashop.com

                        1 réponse Dernière réponse Répondre Citer 0
                        • Olivier75009O Hors-ligne
                          Olivier75009
                          dernière édition par

                          Bon sang mais où avais-je la tête. Merci encore !

                          www.rituel-manucure.com

                          1 réponse Dernière réponse Répondre Citer 0
                          • Premier message
                            Dernier message
                          bug
                          26 sujets
                          1.6
                          24 sujets
                          front-office
                          11 sujets
                          1.5
                          8 sujets
                          1.7
                          5 sujets
                          système
                          4 sujets
                          administration
                          3 sujets
                          hack
                          3 sujets
                          module
                          3 sujets
                          performance
                          3 sujets
                          smtp
                          3 sujets
                          transporteurs
                          3 sujets
                          dashboard
                          2 sujets
                          https
                          2 sujets
                          paypal
                          2 sujets
                          promotions
                          2 sujets