I'm testing with the Foxycart Plugin to update the stock in my code. In the FoxyCartController.php I'm able to filter through the XML feed ok and get the new Stock value but it's doesn't seem to be getting saved.
My current code which picks up the correct product and $newQuantity value ok - but it doesn't seem to save the $newQuantity value back to the stock field in the entry.
//If you have custom code to run for each product, put it here:
$service = craft()->entries;
$entry = $service->getEntryById($product_code);
if ($entry != null) {
$attrs = $entry->getContent();
$newQuantity = $attrs['stock'] - $product_quantity;
$entry->getContent()->setAttributes(array(
'stock' => $newQuantity
));
$service->saveEntry($entry);
//return $entry;
} else {
//return null;
}