Jump to content

Intégration d'un module dans un module AMP


Recommended Posts

Bonjour à tous,

J'ai téléchargé ce module pour mon site afin d'optimiser le nombre de clics sur google. Seul problème, c'est un module extrêmement basique dans lequel aucun des modules du site n'est intégré. Il n'y a donc ni le partage sur les réseaux sociaux, ni les points fidélités, ni un module de ma création affichant les prix des produits en location longue durée.
 

J'ai donc tenté d'intégrer ce dernier module de cette façon : prendre le bout de code de mon module initial; l'intégrer dans le nouveau module amp (dans le fichier eoamp.php), puis faire un include dans la page product.php (il n'y a pas de hook dans les AMP, tout se fait sur la page product.php).  Ca ne fonctionne pas, en effet, le  contenu "dur" de la page tpl s'affiche mais pas les variables, je pense que le problème vient du code inséré dans la page eoamp.php que voici :

public function test($params)
    {
        $product = $this->context->controller->getProduct();
        $categorie=$product->category;
     
                $nom=$product->manufacturer_name;
                $prixencentimes=round(($product->price)*120);
                $curl = curl_init();
                 
                $opts = [
                    CURLOPT_URL => 'urlpersonnaliseedelapi',
                    CURLOPT_RETURNTRANSFER => true,
                ];
                 
                curl_setopt_array($curl, $opts);
                 
                $response = json_decode(curl_exec($curl), true);
                $test = $response['RENT_PRODUCT_WITH_REDEMPTION']['publicPriceWithDurations'];

                $moisdouze=$test[0]['durationInMonths'];
                $moisdixhuit=$test[1]['durationInMonths'];
                $moisvingtquatre=$test[2]['durationInMonths'];
                $moistrentesix=$test[3]['durationInMonths'];

                $loyerdouze=number_format($test[0]['priceInCts']/100, 2);
                $loyerdixhuit=number_format($test[1]['priceInCts']/100, 2);
                $loyervingtquatre=number_format($test[2]['priceInCts']/100, 2);
                $loyertrentesix=number_format($test[3]['priceInCts']/100, 2);

                $paiementdouze=number_format(($test[0]['downPayment']['priceInCts']/100 + $test[1]['priceInCts']/100), 2);
                $paiementdixhuit=number_format(($test[1]['downPayment']['priceInCts']/100 + $test[2]['priceInCts']/100), 2);
                $paiementvingtquatre=number_format(($test[2]['downPayment']['priceInCts']/100 + $test[3]['priceInCts']/100), 2);
                $paiementtrentesix=number_format(($test[3]['downPayment']['priceInCts']/100 + $test[4]['priceInCts']/100), 2);


                $this->context->smarty->assign(array(
                    "moisdouze"=>$moisdouze,
                    "moisdixhuit"=>$moisdixhuit,
                    "moisvingtquatre"=>$moisvingtquatre,
                    "moistrentesix"=>$moistrentesix,
                    "loyerdouze"=>$loyerdouze,
                    "loyerdixhuit"=>$loyerdixhuit,
                    "loyervingtquatre"=>$loyervingtquatre,
                    "loyertrentesix"=>$loyertrentesix,
                    "paiementdouze"=>$paiementdouze,
                    "paiementdixhuit"=>$paiementdixhuit,
                    "paiementvingtquatre"=>$paiementvingtquatre,
                    "paiementtrentesix"=>$paiementtrentesix,




                ));
                if($paiementdouze!=0){
                   return $this->display(__FILE__, "views/templates/front/leasingProduct.tpl");
                }
    }

 

Ce code fonctionne dans le module initial, si vous avez des idées du pourquoi il ne fonctionne pas ici, n'hésitez pas :)

 

Merci d'avance.

 

 

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