Jump to content

Override feature.php


Algirdas
 Share

Recommended Posts

Hello,

 

I'm trying to override faeture.php class and  add custom field to it. I found tutorial how to add custom field to product class, but difference is that feature class don't have __constructor method and I don't know how to add custom field.
Maybe someone could give me example how to do that?

Also, when prestashop updates mysql database by overrided class?

 

Thank you :)

Share this post


Link to post
Share on other sites

The simplest example for your override:

/*
Place this in /override/classes/Feature.php
*/
Feature::$definition['fields']['custom'] = array('type' => ObjectModelCore::TYPE_STRING, 'size' => 100);

class Feature extends FeatureCore
{
	public $custom;
}

Similar, for a feature value, which depends on different languages, you can see bellow:

/*
Place this in /override/classes/FeatureValue.php
*/
FeatureValue::$definition['fields']['custom'] = array('type' => ObjectModelCore::TYPE_STRING, 'lang' = true, 'size' => 100);

class FeatureValue extends FeatureValueCore
{
	public $custom;
}

Don't forget to delete /cache/class_index.php file for changes to take effect.

Edited by cristic (see edit history)

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