Jump to content

Problem with override product price Prestashop 1.7.5

Recommended Posts

Hey !

i have difficulties to override class product.php (prestashop 1.7.5).

I want to add a new price field in back-office for products (which admin can use to add extra price to his products.

I've overrided class Product.php (override/classes/product.php) to add this new field :


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

                                    public $service;

                                    self::$definition['fields']['service'] = [

                                            'type' => self::TYPE_FLOAT,

                                            'required' => true, 'size' => 10


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



And it works, it's in DB, admin can CRUD it.

But, now for calculate price it's a little bit different because i want that the price += service.

So, always in override/classes/product.php, i override public static function priceCalculation() {} with queries to DB (select then update with the result).

But the calculation is done every time I click save on the product sheet in the back office or click on the product sheet in front office (it increments each time) ...

It's not a cache problem, always delete it before trying...

Can just find on the web solutions to add text field, not prices fields...

If anyone can helps :) :)

Thx !

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