Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConvertSerializedDataToJson.php
Go to the documentation of this file.
1 <?php
7 
13 
18 {
22  private $quoteSetup;
23 
27  private $queryModifierFactory;
28 
32  private $queryGenerator;
33 
37  private $aggregatedFieldConverter;
38 
47  public function __construct(
48  QuoteSetup $quoteSetup,
49  AggregatedFieldDataConverter $aggregatedFieldConverter,
50  QueryModifierFactory $queryModifierFactory,
51  Generator $queryGenerator
52  ) {
53  $this->quoteSetup = $quoteSetup;
54  $this->aggregatedFieldConverter = $aggregatedFieldConverter;
55  $this->queryModifierFactory = $queryModifierFactory;
56  $this->queryGenerator = $queryGenerator;
57  }
58 
66  public function convert()
67  {
68  $queryModifier = $this->queryModifierFactory->create(
69  'in',
70  [
71  'values' => [
72  'code' => [
73  'parameters',
74  'info_buyRequest',
75  'attributes',
76  'bundle_option_ids',
77  'bundle_selection_ids',
78  'bundle_selection_attributes',
79  ]
80  ]
81  ]
82  );
83  $this->aggregatedFieldConverter->convert(
84  [
85  new FieldToConvert(
86  SerializedToJson::class,
87  $this->quoteSetup->getTable('quote_payment'),
88  'payment_id',
89  'additional_information'
90  ),
91  new FieldToConvert(
92  SerializedToJson::class,
93  $this->quoteSetup->getTable('quote_payment'),
94  'payment_id',
95  'additional_data'
96  ),
97  new FieldToConvert(
98  SerializedToJson::class,
99  $this->quoteSetup->getTable('quote_address'),
100  'address_id',
101  'applied_taxes'
102  ),
103  new FieldToConvert(
104  SerializedToJson::class,
105  $this->quoteSetup->getTable('quote_item_option'),
106  'option_id',
107  'value',
108  $queryModifier
109  ),
110  ],
111  $this->quoteSetup->getConnection()
112  );
113 
114  $select = $this->quoteSetup->getSetup()
115  ->getConnection()
116  ->select()
117  ->from(
118  $this->quoteSetup->getSetup()
119  ->getTable('catalog_product_option'),
120  ['option_id']
121  )
122  ->where('type = ?', 'file');
123  $iterator = $this->queryGenerator->generate('option_id', $select);
124  foreach ($iterator as $selectByRange) {
125  $codes = $this->quoteSetup->getSetup()
126  ->getConnection()
127  ->fetchCol($selectByRange);
128  $codes = array_map(
129  function ($id) {
130  return 'option_' . $id;
131  },
132  $codes
133  );
134  $queryModifier = $this->queryModifierFactory->create(
135  'in',
136  [
137  'values' => [
138  'code' => $codes
139  ]
140  ]
141  );
142  $this->aggregatedFieldConverter->convert(
143  [
144  new FieldToConvert(
145  SerializedToJson::class,
146  $this->quoteSetup->getTable('quote_item_option'),
147  'option_id',
148  'value',
149  $queryModifier
150  ),
151  ],
152  $this->quoteSetup->getConnection()
153  );
154  }
155  }
156 }
__construct(QuoteSetup $quoteSetup, AggregatedFieldDataConverter $aggregatedFieldConverter, QueryModifierFactory $queryModifierFactory, Generator $queryGenerator)
$id
Definition: fieldset.phtml:14