Unatomisa Posted March 23, 2015 Share Posted March 23, 2015 Bonjour à tous, J'ai ajouté un champ à mon back et front office. J'ai ajouté le champ "Durée de garantie" Dans /override/classes/Product.php j'ai ajouté le code suivant : <?php class Product extends ProductCore { public $garantie; public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null) { Product::$definition['fields']['garantie'] = array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString'); parent::__construct($id_product, $full, $id_lang, $id_shop, $context); } } Le problème, j'aimerais rajouté un champ "Durée de livraison" mais lorsque je recopie le code suivant en changeant ce qui va bien. Mon site devient tout blanc. J'aimerais connaître la démarche pour mettre plusieurs champs dans ce fichier. De plus dans mon backoffice j'ai renseigné ce code dans /override/controllers/admin/templates/products/informations.tpl : <div class="form-group"> <label class="control-label col-lg-3" for="garantie"> <span class="label-tooltip" data-toggle="tooltip" title="{l s='Durée de garantie.'}"> {$bullet_common_field} {l s='Durée de garantie'} </span> </label> <div class="col-lg-3"> <input maxlength="13" type="text" id="garantie" name="garantie" value="{$product->garantie|htmlentitiesUTF8}" /> </div> </div> Mais lorsque je rafraichi ma page, j'ai dans mon champs "array" de marqué et non ma valeur. Si vous pouvez m'aider, car je ne trouve pas la solution. Merci par avance Link to comment Share on other sites More sharing options...
Szed Posted March 24, 2015 Share Posted March 24, 2015 Pour plusieurs champs il ne faut pas tout recopier, juste les lignes nécéssaires : class Product extends ProductCore { public $garantie; public $livraison; public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null) { Product::$definition['fields']['garantie'] = array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString'); Product::$definition['fields']['livraison'] = array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString'); parent::__construct($id_product, $full, $id_lang, $id_shop, $context); } } Et pour l'affichage dans information, des fois $product->garantie peut être un array oui, donc il faut cibler précisément la bonne case (ex : $product->garantie.4) Pour savoir, faite un {$product->garantie|@var_dump} et vous saurez ou est votre valeur dans le tableau. Link to comment Share on other sites More sharing options...
Unatomisa Posted March 25, 2015 Author Share Posted March 25, 2015 Merci beaucoup cela fonctionne parfaitement. Maintenant j'ai compris d’où venait mon erreur. J'ai indiqué {$product->garantie|@var_dump} et dans mon champs je me retrouve avec ceci sans que cela m'aide énormément. Pour Garantie dans mon champs j'ai ceci: <pre class='xdebug-var-dump' dir='ltr'><b>array</b> <i>(size=1)</i> 1 <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'5'</font> <i>(length=1)</i></pre> Pour Date Livraison dans mon champ j'ai ceci : <pre class='xdebug-var-dump' dir='ltr'><b>array</b> <i>(size=1)</i> 1 <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'2 à 3'</font> <i>(length=6)</i></pre> J'ai que le (length=6) et (length=1) qui change, mais je ne vois pas comment l'adapter. Link to comment Share on other sites More sharing options...
Szed Posted March 25, 2015 Share Posted March 25, 2015 Essayez : <input maxlength="13" type="text" id="garantie" name="garantie" value="{$product->garantie.1|htmlentitiesUTF8}" /> Link to comment Share on other sites More sharing options...
Unatomisa Posted March 25, 2015 Author Share Posted March 25, 2015 Super niquel merci beaucoup. J'ai fait de même pour date_livraison.1 et tout marche à la perfection. Encore merci et bonne journée 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