Jump to content

Ajouter un champ html supplémentaire pour vos catégories (ps1.4)


Recommended Posts

Un petit tuto qui peut intéresser tous ceux qui sont encore en version 1.4:

 

http://blog.manit4c.com/2014/09/04/ajouter-un-champ-texte-supplementaire-dans-vos-categories-sous-prestashop-1-4/

 

Il faut simplement changer ses propriétés c'est-à-dire $fieldsSizeLang et $fieldsValidateLang, et d'y ajouter la nouvelle propriété et surcharger les méthodes getFields et getTranslationsFieldsChild.

class Category extends CategoryCore 
{
	public 		$my_new_field;

 	protected 	$fieldsSizeLang = array(
                                         'name' => 64, 
                                         'link_rewrite' => 64,
                                         'meta_title' => 128,
                                         'meta_description' => 255,
                                         'meta_keywords' => 255,
                                         'my_new_field' => 255
                                );
 	protected 	$fieldsValidateLang = array(
                                         'name' => 'isCatalogName', 
                                         'link_rewrite' => 'isLinkRewrite',
                                         'description' => 'isCleanHtml',											
                                         'meta_title' => 'isGenericName',
                                         'meta_description' => 'isGenericName', 
                                         'meta_keywords' => 'isGenericName',
                                         'my_new_field' => 'isString'
                                  );

    public function getFields()
    {
        $fields = parent::getFields();
        $fields['my_new_field'] = pSQL($this->my_new_field);
        return $fields;
    }

    public function getTranslationsFieldsChild()
    {
        parent::validateFieldsLang();
        return ObjectModel::getTranslationsFields(array('name', 'description', 'link_rewrite', 'meta_title', 'meta_keywords', 'meta_description', 'my_new_field'));
    }


}
Edited by zombie process (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...