Plugin Controller - Save Entry 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()-&gt;entries;

    $entry = $service-&gt;getEntryById($product_code);

    if ($entry != null) {
        $attrs = $entry-&gt;getContent();

        $newQuantity = $attrs['stock'] - $product_quantity;


        $entry-&gt;getContent()-&gt;setAttributes(array(
            'stock' =&gt; $newQuantity
        ));

        $service-&gt;saveEntry($entry);

        //return $entry;
    } else {
        //return null;
    }
You're likely getting a validation error that you're not checking for.  Do something like this:

if ($entry-&gt;validate())
{
    $service-&gt;saveEntry($entry);
}
else
{
    $errors = $entry-&gt;getErrors();
}


Update:

Do you get anything if you do:

if (!$service-&gt;saveEntry($entry))
{
    $errors = $entry-&gt;getErrors();
}