Jump to content

add new field in admin product attribute


newbie_presta19
 Share

Recommended Posts

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

Share this post


Link to post
Share on other sites

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),

Share this post


Link to post
Share on other sites

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),
 

Share this post


Link to post
Share on other sites

  • 3 weeks later...
  • 1 month later...

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'),

Share this post


Link to post
Share on other sites

  • 5 months later...

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 ?

Share this post


Link to post
Share on other sites

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 by Loboo (see edit history)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

  • 1 year later...
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

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More