Jump to content

Personnalisation produit


Recommended Posts

Bonjour,

 

 

Je cherche à afficher récupérer les données de personnalisation produit (champ texte) et à afficher le contenu dans un module . Quelqu’un aurait il une idée sur comment procéder ? les différentes manières que j'ai pu tenter ne fonctionnent malheureusement pas.

 

Merci

 

Edited by webspider (see edit history)
Link to comment
Share on other sites

Salut et merci pour ta réponse, ça devrait faire l'affaire.

 

j'ai juste un petit soucis pour récupérer le résultat vers mon tpl :rolleyes: , comme on dit, c'est en forgeant qu'on devient forgeron mais la, j'ai cassé mon enclume à jongler entre les controllers, assign etc... le passage de variables d'une fonction php vers un tpl c'est encore un monde obscur pour moi ! Pourrais tu m'aiguiller sur la marche à suivre ?

 

merci d'avance !

Link to comment
Share on other sites

1) tu as une class maClass.php dans /modules/mon_module/classes

 <?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 [email protected] 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 <[email protected]>
 *  @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 maClass extends ObjectModel {

  public static function getAllCustomisations()
{
$query = new DbQuery();
$query->select('value');
$query->from('customized_data');
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
return $res; 
}

}

2) tu as un controller monController.php qui permet d'afficher une page en front /modules/mon_module/controllers/front
 

<?php
/**
 * 2007-2016 PrestaShop.
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 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/afl-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 [email protected] 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 <[email protected]>
 *  @copyright 2007-2016 PrestaShop SA
 *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 *  International Registered Trademark & Property of PrestaShop SA
 */

// On a besoin de la classe maClass.php
require_once(dirname(__FILE__).'/../../classes/maClass.php');

class MonModuleMonControllerModuleFrontController extends ModuleFrontController {


    public function __construct()
    {
        parent::__construct();

        $this->context = Context::getContext();
    }

    public function init()
    {
        parent::init();
        
     }

    public function initContent()
    {
        parent::initContent();

      // on assign a une variable le resultat (array) de la fonction getAllCustomisations
        $getAllCustomisations = maClass::getAllCustomisations();
      // on envoit la variable à smarty
        $this->context->smarty->assign(
                array(
                        'getAllCustomisations' => $getAllCustomisations,
                        
                )
            );
      //on assigne une vue
        $this->setTemplate('mon_tpl.tpl');
    }

 
}

Edited by Alexandre Carette (see edit history)
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...