public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
if (is_null($value)) {
return [];
}
if (!is_array($value)) {
throw ConversionException::conversionFailed($value, $this->getName());
}
$data = [];
foreach ($value as $item) {
if (!$item instanceof CartItem) {
throw ConversionException::conversionFailed($value, $this->getName());
}
$data[(string) $item->sku()] = ['sku' => (string) $item->sku(), 'quantity' => $item->quantity()];
}
return json_encode($data);
}