我正在尝试以编程方式创建捆绑产品,并通过以下方式设置选项:
$new_options[$count] = array(
'required' => 0,
'position' => 1,
'parent_id' => $parentProduct->getId(),
'type' => 'select',
'title' => $product->getName(),
'default_title' => $product->getName()
);
$new_selections[$count] = array(array(
'product_id' => $product->getEntityId(),
'selection_qty' => $child['qty'],
'selection_can_change_qty' => 0,
'position' => 0,
'is_default' => 1,
'selection_price_type' => 0,
'selection_price_value' => 0.0
));
...
$parentProduct->setBundleOptionsData($new_options);
$parentProduct->setBundleSelectionsData($new_selections);
这看起来是正确的(如https://stackoverflow.com/a/4415800/494643中所述)。但是,它不起作用 - 我收到一个 SQL 异常,抱怨Column 'selection_id' cannot be null'
. 我该如何解决这个问题?选择id是一个auto_increment列,所以在创建之前无法获取,但是看起来无法创建?