Jump to content

add product via php sith a specific tax rate.


peorthyr

Recommended Posts

Good day all.

I'm searching a way to create a new product via PHP, and to add a specific tax rate to it.
 

$product = new Product();
//$product->ean13 = 9999999999999;
 
$product->reference = $etichetta;
$product->name = array((int)Configuration::get('PS_LANG_DEFAULT') =>  $titolo);
$product->description_short = array((int)Configuration::get('PS_LANG_DEFAULT') =>  $testo);
$product->description = array((int)Configuration::get('PS_LANG_DEFAULT') =>  $composizione);
$product->price = $prezzo;
$product->link_rewrite = array((int)Configuration::get('PS_LANG_DEFAULT') => $safeName);
$product->id_category = 23;
$product->id_category_default = 23;
$product->redirect_type = '404';
$product->add();
$product->addToCategories(array(23));
$product->id_tax_rules_group = 3; <------------------- this is not working, the tax is always "the default one".
 
everything is working fine except the taxes, it uses always the default taxes (22%)...
 
what i'm mistaking??
Link to comment
Share on other sites

  • 11 months later...

it mostly depends on your script logic, you can use the PS framework, you can directly update the db, you can even use webservices to achieve that task.

 

sidenote, you can start a new topic by pressing the button "start a new topic" in any thread list on the forum (the page before this one).

 

post here (or on a new topic) your problem, with some code and logic, let's see if there is a way to accomplish that.

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