如何设置捆绑选项,例如产品SKU,Magento 2.1 API的购物车/矿机/物品中的名称

时间:2018-06-25 07:07:49

标签: bundle magento2.1

如何设置捆绑选项,例如产品sku,magento 2.1 api的购物车/地雷/物品中的名称

I am getting the product sku but unable to set in carts product_option extension_attributes and here in bundle_option i want to set this product sku but i am not getting in result when calling api V1/carts/mine/items.

请提出我在代码中做错了什么地方

    $productOption = $this->bundleOptionFactory->create();
    $productOption->setOptionId($optionId);
    $productOption->setOptionSelections($optionSelections);
    $productOption->setOptionQty($optionQty);
    $productOption->setSku($product->getSku());
    $productOptions[] = $productOption;

    $productOption->setBundleOptions($productOptions);

    $productOption->setBundleOption($productOption->getSku());

$extension = $this->productOptionExtensionFactory->create()->setBundleOptions($productOption->getBundleOption());
if (!$this->cartItem->getProductOption()) {
    $this->cartItem->setProductOption($this->productOptionFactory->create());
}
$this->cartItem->getProductOption()->setExtensionAttributes($extension)->setBundleOptions($productOption->getBundleOption());

0 个答案:

没有答案