Jump to content

Webservice API: How to set the product supplier ID


Recommended Posts

I have been able to add a product using the WebService API

but I have not been able to figure out how to set the product supplier id

it does not work when setting creating the product 

e.g.

<product>

<id />
<id_manufacturer />
<id_supplier >6</id_supplier>
...
 
 
Please help
-Tobias
 
Link to comment
Share on other sites

  • 2 weeks later...

I figured it out.... I think it is a bug

the Product.php file inside of classes/ needs to be updated so that the following two methods/functions looks like this

Basically, the problem was that when the WS (Webserivce API) triggered addWs or updateWs, then the SupplierId was never set...

in the code below you can see two rows

if ($success) 

     $this->addSupplierReference($this->id_supplier, 0, $this->supplier_reference, $this->wholesale_price, null);
and that is all that is needed !
 
public function addWs($autodate = true, $null_values = false)
{
$success = $this->add($autodate, $null_values);
if ($success && Configuration::get('PS_SEARCH_INDEXATION'))
Search::indexation(false, $this->id);
if ($success) 
$this->addSupplierReference($this->id_supplier, 0, $this->supplier_reference, $this->wholesale_price, null);
return $success;
}
 
public function updateWs($null_values = false)
{
$success = parent::update($null_values);
if ($success && Configuration::get('PS_SEARCH_INDEXATION'))
Search::indexation(false, $this->id);
if ($success) 
$this->addSupplierReference($this->id_supplier, 0, $this->supplier_reference, $this->wholesale_price, null);
return $success;
}
  • Like 1
Link to comment
Share on other sites

  • 1 month later...
  • 5 months later...

I have the same problem in 1.6.0.14. Any clue?

I see in ps_product table the id_supplier is correct but in Backend of prestashop, in the edit of product is not marked. why?
I see a table called ps_product_supplier that contains id_supplier and id_product and other fields. If i change the id_supplier in this table on Backend of prestashop in the edit of product the supplier change, can i add one row per product with its id_supplier in this table to do this?
I need to change other field or table to do this?

Thanks!

Link to comment
Share on other sites

  • 1 year later...

 

I figured it out.... I think it is a bug

the Product.php file inside of classes/ needs to be updated so that the following two methods/functions looks like this

Basically, the problem was that when the WS (Webserivce API) triggered addWs or updateWs, then the SupplierId was never set...

in the code below you can see two rows

if ($success) 

     $this->addSupplierReference($this->id_supplier, 0, $this->supplier_reference, $this->wholesale_price, null);
and that is all that is needed !
 
public function addWs($autodate = true, $null_values = false)
{
$success = $this->add($autodate, $null_values);
if ($success && Configuration::get('PS_SEARCH_INDEXATION'))
Search::indexation(false, $this->id);
if ($success) 
$this->addSupplierReference($this->id_supplier, 0, $this->supplier_reference, $this->wholesale_price, null);
return $success;
}
 
public function updateWs($null_values = false)
{
$success = parent::update($null_values);
if ($success && Configuration::get('PS_SEARCH_INDEXATION'))
Search::indexation(false, $this->id);
if ($success) 
$this->addSupplierReference($this->id_supplier, 0, $this->supplier_reference, $this->wholesale_price, null);
return $success;
}

 

Thank you very much.

 

This actually works. I'm on the 1.6.1.11 version and this still hasn't been fixed.

Link to comment
Share on other sites

  • 3 years later...

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