2

I'm getting the error at below, when i try to set the configurable attribute, to create configurable product via Magento 2 API:

as described in: http://devdocs.magento.com/guides/v2.2/rest/tutorials/configurable-product/define-config-product-options.html

{"message":"Value index is not specified for an option."}

my code is:

$sampleProductData = array(

'option' => array(
    'attribute_id' => 150, 
    'label' => 'Shoe Size',
    'position' => 0,
    'is_use_default' => true,
    'values' => array(
        'value_index' => '8' ),
), );

$productData = json_encode($sampleProductData);

IMPORTANT NOTE:

150 is 'Shoe Size' attribute ID, and 8 is the shoe size 37's ID

0

There is missing an extra array around the value_index:

$sampleProductData = [
   'option' => [
      'attribute_id' => 150, 
      'label' => 'Shoe Size',
      'position' => 0,
      'is_use_default' => true,
      'values' => [
          [
            'value_index' => 8
          ]
      ]
   ]
];

Official docs: https://devdocs.magento.com/guides/v2.4/rest/tutorials/configurable-product/define-config-product-options.html#set-the-configurable-attribute

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.