6
6
namespace Magento \SalesSampleData \Model \Order ;
7
7
8
8
use Magento \Customer \Api \CustomerRepositoryInterface ;
9
+ use Magento \Framework \App \ObjectManager ;
10
+ use Magento \Framework \Serialize \Serializer \Json ;
9
11
10
12
/**
11
13
* Class Converter
@@ -32,22 +34,30 @@ class Converter
32
34
*/
33
35
protected $ eavConfig ;
34
36
37
+ /**
38
+ * @var Json
39
+ */
40
+ protected $ serializer ;
41
+
35
42
/**
36
43
* @param CustomerRepositoryInterface $customerAccount
37
44
* @param \Magento\Catalog\Model\ProductFactory $productFactory
38
45
* @param \Magento\ConfigurableSampleData\Model\Product\ConverterFactory $productConverterFactory
39
46
* @param \Magento\Eav\Model\Config $eavConfig
47
+ * @param Json $serializer
40
48
*/
41
49
public function __construct (
42
50
CustomerRepositoryInterface $ customerAccount ,
43
51
\Magento \Catalog \Model \ProductFactory $ productFactory ,
44
52
\Magento \ConfigurableSampleData \Model \Product \ConverterFactory $ productConverterFactory ,
45
- \Magento \Eav \Model \Config $ eavConfig
53
+ \Magento \Eav \Model \Config $ eavConfig ,
54
+ Json $ serializer = null
46
55
) {
47
56
$ this ->customerRepository = $ customerAccount ;
48
57
$ this ->productFactory = $ productFactory ;
49
58
$ this ->productConverter = $ productConverterFactory ->create ();
50
59
$ this ->eavConfig = $ eavConfig ;
60
+ $ this ->serializer = $ serializer ?: ObjectManager::getInstance ()->get (Json::class);
51
61
}
52
62
53
63
/**
@@ -164,14 +174,13 @@ protected function getAddresses(\Magento\Customer\Api\Data\AddressInterface $add
164
174
*/
165
175
protected function convertProductData ($ productData )
166
176
{
167
- $ productValues = unserialize ($ productData );
177
+ $ productValues = $ this -> serializer -> unserialize ($ productData );
168
178
$ productId = $ this ->getProductData ($ productValues ['sku ' ])->getId ();
169
179
$ productData = ['qty ' => $ productValues ['qty ' ]];
170
180
if (isset ($ productValues ['configurable_options ' ])) {
171
181
$ productData ['super_attribute ' ] = $ this ->getProductAttributes ($ productValues ['configurable_options ' ]);
172
182
}
173
183
return [$ productId => $ productData ];
174
-
175
184
}
176
185
177
186
/**
0 commit comments