Having a little trouble with the Bigcommerce API when trying to access Product SKU's 'Options' array_object.
I can access everything else within the SKU object, just not the Options
- doing a print_r
on the $sku->options
doesn't show any returned data and var_dump shows '(bool)false'
. Here is my code:
$filter = array('sku' => '940801DB');
$skus = Bigcommerce::getSkus($filter);
foreach ( $skus as $sku ){
echo '<pre>';
print_r( $sku->options );
echo '</pre>';
}
Any ideas how to access this array/object?
Further info:
If I print_r($sku) I get:
Array
(
[0] => Bigcommerce\Api\Resources\Sku Object
(
[ignoreOnCreate:protected] => Array
(
[0] => product_id
)
[ignoreOnUpdate:protected] => Array
(
[0] => id
[1] => product_id
)
[fields:protected] => stdClass Object
(
[id] => 1
[product_id] => 225
[sku] => 940801DB
[cost_price] => 0.0000
[upc] =>
[inventory_level] => 0
[inventory_warning_level] => 0
[bin_picking_number] =>
[options] => Array
(
[0] => stdClass Object
(
[product_option_id] => 1
[option_value_id] => 834
)
[1] => stdClass Object
(
[product_option_id] => 2
[option_value_id] => 829
)
[2] => stdClass Object
(
[product_option_id] => 3
[option_value_id] => 827
)
)
)
[id:protected] => 1
[ignoreIfZero:protected] => Array
(
)
[fieldMap:protected] => Array
(
)
)
)
This seems like a bug of Bigcommerce API. I installed it using composer, if you take a look at the source code of Bigcommerce API, inside vendor/bigcommerce/api/src/Bigcommerce/Api/Resources/Sku.php:
See that it gets $this->fields->options->resource, but the options array doesn't have resource in it. In products it's like this:
but in sku it's this:
seems like a bug to me.