bigcommerce-api-php
bigcommerce-api-php copied to clipboard
Uncaught Client Error (400): The field 'calculated_price' cannot be written to.
Expected behavior
$product->update(); //updates product
Actual behavior
PHP Fatal error: Uncaught Client Error (400): The field 'calculated_price' cannot be written to. Please remove it from your request before trying again.
thrown in /vendor/bigcommerce/api/src/Bigcommerce/Api/Connection.php on line 286
Steps to reproduce behavior
- load product via API (I'm doing this from
BigCommerce::getProducts()) - alter
$product->categories = [1,2,3];(they are valid id's for categories that exist) -
$product->save()
I am using PHP in CLI SAPI if that could be the cause. I'm likely going to see if I can patch also...
added the following to $ignoreOnUpdate
'calculated_price',
'primary_image',
'downloads',
'reviews',
);
Seems to do the trick. Not sure how on earth it works for other operations. All these seem like linked fields or calculated property values. Perhaps instead of read-only fields, these could become methods? It's just that it seems like a heap of work to do to emulate a language feature that's not there.
Categories are also much harder to work with compared to product images.