Skip to content

Commit 22df83c

Browse files
author
Igor Melnikov
committed
MAGETWO-62902: Bundle and custom options of type file not converted
- Use \Magento\Sales\Setup\SerializedDataConverter for sales_order_item.product_options
1 parent b723cb1 commit 22df83c

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

app/code/Magento/Sales/Setup/ConvertSerializedDataToJson.php

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Framework\DB\FieldDataConverterFactory;
99
use Magento\Framework\DB\DataConverter\SerializedToJson;
10+
use Magento\Framework\DB\FieldDataConverter;
1011

1112
/**
1213
* Convert serialized data in sales tables to JSON
@@ -23,29 +24,38 @@ class ConvertSerializedDataToJson
2324
*/
2425
private $fieldDataConverterFactory;
2526

27+
/**
28+
* @var array
29+
*/
30+
private $fieldDataConverters = [];
31+
2632
/**
2733
* @var array
2834
*/
2935
private $fieldsToUpdate = [
3036
[
3137
'table' => 'sales_order_item',
3238
'identifier' => 'item_id',
33-
'title' => 'product_options'
39+
'title' => 'product_options',
40+
'data_converter' => SerializedDataConverter::class
3441
],
3542
[
3643
'table' => 'sales_shipment',
3744
'identifier' => 'entity_id',
38-
'title' => 'packages'
45+
'title' => 'packages',
46+
'data_converter' => SerializedToJson::class
3947
],
4048
[
4149
'table' => 'sales_order_payment',
4250
'identifier' => 'entity_id',
43-
'title' => 'additional_information'
51+
'title' => 'additional_information',
52+
'data_converter' => SerializedToJson::class
4453
],
4554
[
4655
'table' => 'sales_payment_transaction',
4756
'identifier' => 'transaction_id',
48-
'title' => 'additional_information'
57+
'title' => 'additional_information',
58+
'data_converter' => SerializedToJson::class
4959
]
5060
];
5161

@@ -74,8 +84,8 @@ public function __construct(
7484
*/
7585
public function convert()
7686
{
77-
$fieldDataConverter = $this->fieldDataConverterFactory->create(SerializedToJson::class);
7887
foreach ($this->fieldsToUpdate as $field) {
88+
$fieldDataConverter = $this->getFieldDataConverter($field['data_converter']);
7989
$fieldDataConverter->convert(
8090
$this->salesSetup->getConnection(),
8191
$this->salesSetup->getTable($field['table']),
@@ -84,4 +94,20 @@ public function convert()
8494
);
8595
}
8696
}
97+
98+
/**
99+
* Get field data converter
100+
*
101+
* @param string $dataConverterClassName
102+
* @return FieldDataConverter
103+
*/
104+
private function getFieldDataConverter($dataConverterClassName)
105+
{
106+
if (!isset($this->fieldDataConverters[$dataConverterClassName])) {
107+
$this->fieldDataConverters[$dataConverterClassName] = $this->fieldDataConverterFactory->create(
108+
$dataConverterClassName
109+
);
110+
}
111+
return $this->fieldDataConverters[$dataConverterClassName];
112+
}
87113
}

0 commit comments

Comments
 (0)