Skip to content
Snippets Groups Projects
Commit 22df83cd authored by Igor Melnikov's avatar Igor Melnikov
Browse files

MAGETWO-62902: Bundle and custom options of type file not converted

- Use \Magento\Sales\Setup\SerializedDataConverter for sales_order_item.product_options
parent b723cb12
Branches
No related merge requests found
......@@ -7,6 +7,7 @@ namespace Magento\Sales\Setup;
use Magento\Framework\DB\FieldDataConverterFactory;
use Magento\Framework\DB\DataConverter\SerializedToJson;
use Magento\Framework\DB\FieldDataConverter;
/**
* Convert serialized data in sales tables to JSON
......@@ -23,6 +24,11 @@ class ConvertSerializedDataToJson
*/
private $fieldDataConverterFactory;
/**
* @var array
*/
private $fieldDataConverters = [];
/**
* @var array
*/
......@@ -30,22 +36,26 @@ class ConvertSerializedDataToJson
[
'table' => 'sales_order_item',
'identifier' => 'item_id',
'title' => 'product_options'
'title' => 'product_options',
'data_converter' => SerializedDataConverter::class
],
[
'table' => 'sales_shipment',
'identifier' => 'entity_id',
'title' => 'packages'
'title' => 'packages',
'data_converter' => SerializedToJson::class
],
[
'table' => 'sales_order_payment',
'identifier' => 'entity_id',
'title' => 'additional_information'
'title' => 'additional_information',
'data_converter' => SerializedToJson::class
],
[
'table' => 'sales_payment_transaction',
'identifier' => 'transaction_id',
'title' => 'additional_information'
'title' => 'additional_information',
'data_converter' => SerializedToJson::class
]
];
......@@ -74,8 +84,8 @@ class ConvertSerializedDataToJson
*/
public function convert()
{
$fieldDataConverter = $this->fieldDataConverterFactory->create(SerializedToJson::class);
foreach ($this->fieldsToUpdate as $field) {
$fieldDataConverter = $this->getFieldDataConverter($field['data_converter']);
$fieldDataConverter->convert(
$this->salesSetup->getConnection(),
$this->salesSetup->getTable($field['table']),
......@@ -84,4 +94,20 @@ class ConvertSerializedDataToJson
);
}
}
/**
* Get field data converter
*
* @param string $dataConverterClassName
* @return FieldDataConverter
*/
private function getFieldDataConverter($dataConverterClassName)
{
if (!isset($this->fieldDataConverters[$dataConverterClassName])) {
$this->fieldDataConverters[$dataConverterClassName] = $this->fieldDataConverterFactory->create(
$dataConverterClassName
);
}
return $this->fieldDataConverters[$dataConverterClassName];
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment