Récemment


Rendre le module mailjet GDPR


  • legacy

    Bonjour,

    Voici une astuce pour rendre le module mailjet RGPD

    Avant toute chose la version du module utilisée est la 3.4.14 disponible ici :

    https://github.com/mailjet/prestashop-mailjet-plugin-apiv3/releases

    Ouvrir le fichier mailjet.php

    A la fin du fichier ajouter avant le dernier }

        public function hookActionExportGDPRData($customer)
        {
            if (!Tools::isEmpty($customer['email']) && Validate::isEmail($customer['email'])) {
    
                if (!$customer) {
                    return false;
                }
    
                $initialSynchronization = new HooksSynchronizationSingleUser(MailjetTemplate::getApi());
                $customerMailJet = $initialSynchronization->getCustomerByEmail($customer['email']);
                
                if( !$customerMailJet || empty($customerMailJet) ) {
                    return json_encode($this->l('Mailjet : Unable to export customer using email.'));
                }
    
    
                $dateAdd = new DateTime($customerMailJet->Data[0]->CreatedAt);
                $dateLastActivity = new DateTime($customerMailJet->Data[0]->LastActivityAt);      
    
                $return[] = [
                    $this->l('Email') => $customerMailJet->Data[0]->Email,
                    $this->l('Date add') => $dateAdd->format('Y-m-d H:i:s'),
                    $this->l('Newsletters sended') => $customerMailJet->Data[0]->DeliveredCount,
                    $this->l('Last Activity') =>  $dateLastActivity->format('Y-m-d H:i:s'), 
                ];
    
                return  json_encode($return);
    
            }
        }
    
        public function hookRegisterGDPRConsent($param)
        {
    
            return;
        }
    
    

    Ouvrir le fichier classes/hooks/synchronization/SingleUser.php

    Ajouter à la fin juste avant le dernier }

        /**
         * Get Contact information by email
         * @param string $email
         * @return object
         */
        public function getCustomerByEmail($email)
        {
            $apiOverlay = $this->getApiOverlay();
    
            $contact= $apiOverlay->getContactByEmail($email);
    
            if (!$contact) {
                return false;
            }
    
            return $contact;
    
        }
    
    

    Greffer le module sur le deux nouveaux hooks

    Enjoy !

    0_1530016824018_mail-jet-gdpr.png

    Dans la logique on a pas besoin du hook delete car il y a déjà une action sur les hook pour ça ... au pire c'est quelques lignes de codes


Se connecter pour répondre