Jump to content

création champs personnalisés dans fiches produits


Recommended Posts

Bonjour,

 

j'ai suivi le tuto suivant pour rajouter un champ dans la fiche produit.

 

http://www.paulineghiazza.fr/prestashop/ajouter-un-champ-dans-le-backoffice-prestashop-1-5/#comment-58

 

J'ai bien créer dans la table ps_product_lang un champ :

 

 

 

contreindication text utf8_general_ci Oui NULL

 

 

 

J'ai overrider le fichier product.php avec ces informations :

 

public $contreindication;

 

public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null)

{

Product::$definition['fields']['contreindication'] = array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString');

parent::__construct($id_product, $full, $id_lang, $id_shop, $context);

}

 

 

 

J'ai ensuite rajouter dans l'admin du template :

 

 

 

<tr>

<td class="col-left">

{include file="controllers/products/multishop/checkbox.tpl" field="contreindication" type="tinymce" multilang="true"}

<label>{$bullet_common_field} {l s='Contre indication :'}<br /></label>

<p class="product_description">({l s='contre indication'})</p>

</td>

<td style="padding-bottom:5px;">

{include file="controllers/products/textarea_lang.tpl" languages=$languages

input_name='contreindication'

input_value=$product->contreindication

}

<p class="clear"></p>

</td>

</tr>

 

Ensuite j'appelle l'info dans mon template.

 

Le truc c'est que l'info ne rentre pas en bdd et ne s'affiche pas non plus en backoffice (ni en front ) même si je la rentre en manuelle.

 

Si vous avez une idée je suis preneur.

 

Cordialement

Link to comment
Share on other sites

Bonjour Carl,

 

1) tu doit ajouter dans la classe ProductCore (tu troveras dans le répertoire classes/Product.php) le champs

/** @var string contreindication */

public $contreindication;

 

2) tu doit ajouter dans le static $definition dans le variable 'fields' la définition suivante

'contreindication' => array('type' => self::TYPE_STRING, 'shop' => true, 'validate' => 'isString'),

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