Jump to content

Update Product Status with webservice


nam797

Recommended Posts

Hello All,
 
 
I am creating a script that will update the status of a product through the PrestaShop web service. It works but is very slow. Has anyone here done this before? When I update the qty of a product it is really fast. Below is the code I am using to update the status. I am also using the PrestaShopWebservice class.

 

 

$xml = $this->prestaShop->get(['resource' => 'products', 'id' => $productId]);
$resources = $xml->children()->children();

// Unset fields that may not be updated
unset($resources->manufacturer_name);
unset($resources->quantity);

$resources->id = $productId;
$resources->active = 0;

//echo $xml->asXML();die;
try {
    $opt = array('resource' => 'products');
    $opt['putXml'] = $xml->asXML();
    $opt['id'] = $productId ;
    $xml = $this->prestaShop->edit($opt);
}catch (PrestaShopWebserviceException $ex) {
    echo $ex->getMessage();
}

 

 

Thanks,

Nathan 

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