Jump to content

Overriding functions and adding more parameters


solidsteak

Recommended Posts

I am overriding a function that takes a certain set of parameters. In my override, I wish to add an additional parameter. In dev mode, I get the error:

 

 

[2048] Declaration of Product::addAttribute() should be compatible with ProductCore::addAttribute($price, $weight, $unit_impact, $ecotax, $id_images, $reference, $ean13, $default, $location = NULL, $upc = NULL, $minimal_quantity = 1, array $id_shop_list = Array, $available_date = NULL)

 

I'm assuming that because of the additional parameter, the override is not matching up with the original function. If so, what are possible solutions? Or do I have to modify the core files?

Link to comment
Share on other sites

 

I'm assuming that because of the additional parameter, the override is not matching up with the original function.

 

Correct.

 

 

If so, what are possible solutions?

 

What's the extra parameter you're trying to add?

 

 

Or do I have to modify the core files?

 

No - don't modify the core files.

 

If you explain what you're trying to add, or what you're hoping to achieve, then a solution may be found.

Link to comment
Share on other sites

My understanding is the parameter is just for passing the value of the new field. For example in Product.php

addAttribute($price, $weight, $unit_impact, $ecotax, $id_images, $reference, $ean13, $default, $location = NULL, $upc = NULL, $minimal_quantity = 1, array $id_shop_list = Array, $available_date = NULL)
{
...
}

Much like $upc, $reference, or $ean13, I'm just adding an additional field.

Edited by solidsteak (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...