I try to update shipping method. I know, that I finally have to update SalesChannel with new Shipping object, but I will get error:
1. [/] Expected data to be array.
#[NoReturn]
private function assignShippingObject(object $shippingObject): void
{
$salesChannels = $this->database->readTableSalesChannel(Context::createDefaultContext());
foreach ($salesChannels as $salesChannel) {
$shippingMethods = $salesChannel->getShippingMethods();
$shippingMethods->add($shippingObject);
$salesChannelData[] = [
'id' => $salesChannel->getId(),
'shippingMethods' => $shippingMethods
];
$this->database->updateSalesChannel(Context::createDefaultContext(), $salesChannelData);
}
}
If I try like this:['shippingMethods' => $shippingMethods]
I will get error:Argument #1 ($key) must be of type string, int given, 'cause first key in array is 0,now! Also this will not fix my problem:'shippingMethods' => $shippingMethods->getIds()
Any idea, how to update SalesChannel with shipping object - $shippingObject - ?
If I will try like this....
$salesChannelData[] = [
'id' => $salesChannel->getId(),
'shippingMethods' => ['id'=>'018ddbaf0ac3762797b951b4ab908282']
];
