I have had another stab at this issue. This issue I faced is that when I created a product without defining a Variant, an empty variant with no SKU or price was created. When I wanted to create a new Variant where a Variant title is not needed, it failed because of the empty Variant.
I have changed my code to the following:
array(
'product' => array(
'title' => $title,
'body_html' => $bodyHtml,
'vendor' => $data['vendor'],
'product_type' => $data['type'],
'tags' => implode(', ', $data['tag']),
'published' => false,
),
'variants' => array(
0 => array(
'option1' => (empty($variantTitle) ? 'Default' : $variantTitle),
'price' => $variantPrice,
'sku' => $data['sku']
),
);
This, more or less works. I say more or less because when I search for the SKU, in this case 40447, the product appears in the search results however the Variant list shows one Variant which is empty.
How can the search work on the SKU where it seems the SKU has not been saved?
![]()
![]()