newbie_presta19 Posted May 25, 2016 Share Posted May 25, 2016 I want to create a link on the product attributes so that when customers choose attribute it directly open product page. My idea is I want to create a new column in database 'attribute_lang'. so my question is how to make one new column in the database that can be accessed in javascript and .tpl? Please help me Link to comment Share on other sites More sharing options...
shokinro Posted May 28, 2016 Share Posted May 28, 2016 You will have to follow steps below 1. Add the field to your database table ps_attribute_lang 2. Add this field to class definition /classes/Attribute.php Please note you will need to make it as multiple language field by adding line to after the name line. /* Lang fields */ 'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128), Link to comment Share on other sites More sharing options...
newbie_presta19 Posted May 29, 2016 Author Share Posted May 29, 2016 (edited) Thank you Shokinro for your reply. Can you explain the process more clearly? of adding fields in the database, adding data to the database, and used in .tpl Edited May 29, 2016 by newbie_presta19 (see edit history) Link to comment Share on other sites More sharing options...
Nikpro Posted May 29, 2016 Share Posted May 29, 2016 please give all descrition how to doit Link to comment Share on other sites More sharing options...
shokinro Posted May 29, 2016 Share Posted May 29, 2016 OK, here is more detailed instructions, assume your new field is "new_field" 1 .Add a new column "new_field" to database table ps_attribute with type of varchar(1000) 2. Add following line in file /classes/Attribute.php public $new_field; after this line 3. Add following line in the same file 'new_field' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 2000), after this line 'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128), Link to comment Share on other sites More sharing options...
mihaiww Posted May 31, 2016 Share Posted May 31, 2016 it is displayed but not save in database Link to comment Share on other sites More sharing options...
vekia Posted May 31, 2016 Share Posted May 31, 2016 you can find several guides around the internet related to this, for exmaple - mine: new product fields tutorial Link to comment Share on other sites More sharing options...
newbie_presta19 Posted June 16, 2016 Author Share Posted June 16, 2016 (edited) Hi, Vekia. Thanks for your reply. How to add new field for product attribute in back office ? Edited June 16, 2016 by newbie_presta19 (see edit history) Link to comment Share on other sites More sharing options...
Viral.w3nuts Posted August 3, 2016 Share Posted August 3, 2016 Same Requirement : I am using PS 1.6.1.4 But no luck getting error message while updating An error occurred while updating an object. product () 1) Added new field in "PREFIX_product" table 2) Updated "information.tpl" file =============================== Then updated classes/Product.php /** @var string Tax rate */ public $product_keyfeatures; And 'product_keyfeatures' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'), Link to comment Share on other sites More sharing options...
bonsaiko Posted January 19, 2017 Share Posted January 19, 2017 Hello, I was able to add new fields in the database and it works great. But now I need to add a kind of "enum" field. That's what I did but I'm wonering how it will work with the languages ? It's ok now that I have only one language, but it will be a problem when I add another language... Could you please help me ? Link to comment Share on other sites More sharing options...
Loboo Posted January 20, 2017 Share Posted January 20, 2017 (edited) I need same but for Prestashop 1.7, i dont know how i can get value from DisplayAdminProductsExtra hook and update db. Update: OK, i did it, but i have another question: Maybe someone know, how i can override product classes ? Edited January 20, 2017 by Loboo (see edit history) Link to comment Share on other sites More sharing options...
shokinro Posted January 20, 2017 Share Posted January 20, 2017 Maybe someone know, how i can override product classes ? It should be same for PrestaShop 1.6x and 1.7x. You can just create a override class Product.php under following folder so that it will override core Product class /override/classes/Product.php make sure you declare the class class Product extends ProductCore { .... Link to comment Share on other sites More sharing options...
wdv94 Posted February 21, 2018 Share Posted February 21, 2018 On 20/1/2017 at 1:08 PM, Loboo said: I need same but for Prestashop 1.7, i dont know how i can get value from DisplayAdminProductsExtra hook and update db. Update: OK, i did it, but i have another question: Maybe someone know, how i can override product classes ? How do you resolve it? I don't know how to get POST parameter in actionProductUpdate hook 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