Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PrepareInitialCheckoutConfiguration.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Eav\Setup\EavSetupFactory;
15 
21 {
25  private $moduleDataSetup;
26 
30  private $eavSetupFactory;
31 
35  private $customerAddress;
36 
41  public function __construct(
42  ModuleDataSetupInterface $moduleDataSetup,
43  EavSetupFactory $eavSetupFactory,
44  \Magento\Customer\Helper\Address $customerAddress
45  ) {
46  $this->moduleDataSetup = $moduleDataSetup;
47  $this->eavSetupFactory = $eavSetupFactory;
48  $this->customerAddress = $customerAddress;
49  }
50 
57  public function apply()
58  {
60  $eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
61 
62  $this->moduleDataSetup->getConnection()->startSetup();
63 
64  $connection = $this->moduleDataSetup->getConnection();
65 
66  $select = $connection->select()->from(
67  $this->moduleDataSetup->getTable('core_config_data'),
68  'COUNT(*)'
69  )->where(
70  'path=?',
71  'customer/address/prefix_show'
72  )->where(
73  'value NOT LIKE ?',
74  '0'
75  );
76  $showPrefix = (bool)$this->customerAddress->getConfig('prefix_show')
77  || $connection->fetchOne($select) > 0;
78 
79  $select = $connection->select()->from(
80  $this->moduleDataSetup->getTable('core_config_data'),
81  'COUNT(*)'
82  )->where(
83  'path=?',
84  'customer/address/middlename_show'
85  )->where(
86  'value NOT LIKE ?',
87  '0'
88  );
89  $showMiddlename = (bool)$this->customerAddress->getConfig('middlename_show')
90  || $connection->fetchOne($select) > 0;
91 
92  $select = $connection->select()->from(
93  $this->moduleDataSetup->getTable('core_config_data'),
94  'COUNT(*)'
95  )->where(
96  'path=?',
97  'customer/address/suffix_show'
98  )->where(
99  'value NOT LIKE ?',
100  '0'
101  );
102  $showSuffix = (bool)$this->customerAddress->getConfig('suffix_show')
103  || $connection->fetchOne($select) > 0;
104 
105  $select = $connection->select()->from(
106  $this->moduleDataSetup->getTable('core_config_data'),
107  'COUNT(*)'
108  )->where(
109  'path=?',
110  'customer/address/dob_show'
111  )->where(
112  'value NOT LIKE ?',
113  '0'
114  );
115  $showDob = (bool)$this->customerAddress->getConfig('dob_show')
116  || $connection->fetchOne($select) > 0;
117 
118  $select = $connection->select()->from(
119  $this->moduleDataSetup->getTable('core_config_data'),
120  'COUNT(*)'
121  )->where(
122  'path=?',
123  'customer/address/taxvat_show'
124  )->where(
125  'value NOT LIKE ?',
126  '0'
127  );
128  $showTaxVat = (bool)$this->customerAddress->getConfig('taxvat_show')
129  || $connection->fetchOne($select) > 0;
130 
131  $customerEntityTypeId = $eavSetup->getEntityTypeId('customer');
132  $addressEntityTypeId = $eavSetup->getEntityTypeId('customer_address');
133 
140  $connection->insert(
141  $this->moduleDataSetup->getTable('eav_form_type'),
142  [
143  'code' => 'checkout_onepage_register',
144  'label' => 'checkout_onepage_register',
145  'is_system' => 1,
146  'theme' => '',
147  'store_id' => 0
148  ]
149  );
150  $formTypeId = $connection->lastInsertId($this->moduleDataSetup->getTable('eav_form_type'));
151 
152  $connection->insert(
153  $this->moduleDataSetup->getTable('eav_form_type_entity'),
154  ['type_id' => $formTypeId, 'entity_type_id' => $customerEntityTypeId]
155  );
156  $connection->insert(
157  $this->moduleDataSetup->getTable('eav_form_type_entity'),
158  ['type_id' => $formTypeId, 'entity_type_id' => $addressEntityTypeId]
159  );
160 
161  $elementSort = 0;
162  if ($showPrefix) {
163  $connection->insert(
164  $this->moduleDataSetup->getTable('eav_form_element'),
165  [
166  'type_id' => $formTypeId,
167  'fieldset_id' => null,
168  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'prefix'),
169  'sort_order' => $elementSort++
170  ]
171  );
172  }
173  $connection->insert(
174  $this->moduleDataSetup->getTable('eav_form_element'),
175  [
176  'type_id' => $formTypeId,
177  'fieldset_id' => null,
178  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'firstname'),
179  'sort_order' => $elementSort++
180  ]
181  );
182  if ($showMiddlename) {
183  $connection->insert(
184  $this->moduleDataSetup->getTable('eav_form_element'),
185  [
186  'type_id' => $formTypeId,
187  'fieldset_id' => null,
188  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'middlename'),
189  'sort_order' => $elementSort++
190  ]
191  );
192  }
193  $connection->insert(
194  $this->moduleDataSetup->getTable('eav_form_element'),
195  [
196  'type_id' => $formTypeId,
197  'fieldset_id' => null,
198  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'lastname'),
199  'sort_order' => $elementSort++
200  ]
201  );
202  if ($showSuffix) {
203  $connection->insert(
204  $this->moduleDataSetup->getTable('eav_form_element'),
205  [
206  'type_id' => $formTypeId,
207  'fieldset_id' => null,
208  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'suffix'),
209  'sort_order' => $elementSort++
210  ]
211  );
212  }
213  $connection->insert(
214  $this->moduleDataSetup->getTable('eav_form_element'),
215  [
216  'type_id' => $formTypeId,
217  'fieldset_id' => null,
218  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'company'),
219  'sort_order' => $elementSort++
220  ]
221  );
222  $connection->insert(
223  $this->moduleDataSetup->getTable('eav_form_element'),
224  [
225  'type_id' => $formTypeId,
226  'fieldset_id' => null,
227  'attribute_id' => $eavSetup->getAttributeId($customerEntityTypeId, 'email'),
228  'sort_order' => $elementSort++
229  ]
230  );
231  $connection->insert(
232  $this->moduleDataSetup->getTable('eav_form_element'),
233  [
234  'type_id' => $formTypeId,
235  'fieldset_id' => null,
236  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'street'),
237  'sort_order' => $elementSort++
238  ]
239  );
240  $connection->insert(
241  $this->moduleDataSetup->getTable('eav_form_element'),
242  [
243  'type_id' => $formTypeId,
244  'fieldset_id' => null,
245  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'city'),
246  'sort_order' => $elementSort++
247  ]
248  );
249  $connection->insert(
250  $this->moduleDataSetup->getTable('eav_form_element'),
251  [
252  'type_id' => $formTypeId,
253  'fieldset_id' => null,
254  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'region'),
255  'sort_order' => $elementSort++
256  ]
257  );
258  $connection->insert(
259  $this->moduleDataSetup->getTable('eav_form_element'),
260  [
261  'type_id' => $formTypeId,
262  'fieldset_id' => null,
263  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'postcode'),
264  'sort_order' => $elementSort++
265  ]
266  );
267  $connection->insert(
268  $this->moduleDataSetup->getTable('eav_form_element'),
269  [
270  'type_id' => $formTypeId,
271  'fieldset_id' => null,
272  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'country_id'),
273  'sort_order' => $elementSort++
274  ]
275  );
276  $connection->insert(
277  $this->moduleDataSetup->getTable('eav_form_element'),
278  [
279  'type_id' => $formTypeId,
280  'fieldset_id' => null,
281  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'telephone'),
282  'sort_order' => $elementSort++
283  ]
284  );
285  $connection->insert(
286  $this->moduleDataSetup->getTable('eav_form_element'),
287  [
288  'type_id' => $formTypeId,
289  'fieldset_id' => null,
290  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'fax'),
291  'sort_order' => $elementSort++
292  ]
293  );
294  if ($showDob) {
295  $connection->insert(
296  $this->moduleDataSetup->getTable('eav_form_element'),
297  [
298  'type_id' => $formTypeId,
299  'fieldset_id' => null,
300  'attribute_id' => $eavSetup->getAttributeId($customerEntityTypeId, 'dob'),
301  'sort_order' => $elementSort++
302  ]
303  );
304  }
305  if ($showTaxVat) {
306  $connection->insert(
307  $this->moduleDataSetup->getTable('eav_form_element'),
308  [
309  'type_id' => $formTypeId,
310  'fieldset_id' => null,
311  'attribute_id' => $eavSetup->getAttributeId($customerEntityTypeId, 'taxvat'),
312  'sort_order' => $elementSort++
313  ]
314  );
315  }
316 
323  $connection->insert(
324  $this->moduleDataSetup->getTable('eav_form_type'),
325  [
326  'code' => 'checkout_onepage_register_guest',
327  'label' => 'checkout_onepage_register_guest',
328  'is_system' => 1,
329  'theme' => '',
330  'store_id' => 0
331  ]
332  );
333  $formTypeId = $connection->lastInsertId($this->moduleDataSetup->getTable('eav_form_type'));
334 
335  $connection->insert(
336  $this->moduleDataSetup->getTable('eav_form_type_entity'),
337  ['type_id' => $formTypeId, 'entity_type_id' => $customerEntityTypeId]
338  );
339  $connection->insert(
340  $this->moduleDataSetup->getTable('eav_form_type_entity'),
341  ['type_id' => $formTypeId, 'entity_type_id' => $addressEntityTypeId]
342  );
343 
344  $elementSort = 0;
345  if ($showPrefix) {
346  $connection->insert(
347  $this->moduleDataSetup->getTable('eav_form_element'),
348  [
349  'type_id' => $formTypeId,
350  'fieldset_id' => null,
351  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'prefix'),
352  'sort_order' => $elementSort++
353  ]
354  );
355  }
356  $connection->insert(
357  $this->moduleDataSetup->getTable('eav_form_element'),
358  [
359  'type_id' => $formTypeId,
360  'fieldset_id' => null,
361  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'firstname'),
362  'sort_order' => $elementSort++
363  ]
364  );
365  if ($showMiddlename) {
366  $connection->insert(
367  $this->moduleDataSetup->getTable('eav_form_element'),
368  [
369  'type_id' => $formTypeId,
370  'fieldset_id' => null,
371  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'middlename'),
372  'sort_order' => $elementSort++
373  ]
374  );
375  }
376  $connection->insert(
377  $this->moduleDataSetup->getTable('eav_form_element'),
378  [
379  'type_id' => $formTypeId,
380  'fieldset_id' => null,
381  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'lastname'),
382  'sort_order' => $elementSort++
383  ]
384  );
385  if ($showSuffix) {
386  $connection->insert(
387  $this->moduleDataSetup->getTable('eav_form_element'),
388  [
389  'type_id' => $formTypeId,
390  'fieldset_id' => null,
391  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'suffix'),
392  'sort_order' => $elementSort++
393  ]
394  );
395  }
396  $connection->insert(
397  $this->moduleDataSetup->getTable('eav_form_element'),
398  [
399  'type_id' => $formTypeId,
400  'fieldset_id' => null,
401  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'company'),
402  'sort_order' => $elementSort++
403  ]
404  );
405  $connection->insert(
406  $this->moduleDataSetup->getTable('eav_form_element'),
407  [
408  'type_id' => $formTypeId,
409  'fieldset_id' => null,
410  'attribute_id' => $eavSetup->getAttributeId($customerEntityTypeId, 'email'),
411  'sort_order' => $elementSort++
412  ]
413  );
414  $connection->insert(
415  $this->moduleDataSetup->getTable('eav_form_element'),
416  [
417  'type_id' => $formTypeId,
418  'fieldset_id' => null,
419  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'street'),
420  'sort_order' => $elementSort++
421  ]
422  );
423  $connection->insert(
424  $this->moduleDataSetup->getTable('eav_form_element'),
425  [
426  'type_id' => $formTypeId,
427  'fieldset_id' => null,
428  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'city'),
429  'sort_order' => $elementSort++
430  ]
431  );
432  $connection->insert(
433  $this->moduleDataSetup->getTable('eav_form_element'),
434  [
435  'type_id' => $formTypeId,
436  'fieldset_id' => null,
437  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'region'),
438  'sort_order' => $elementSort++
439  ]
440  );
441  $connection->insert(
442  $this->moduleDataSetup->getTable('eav_form_element'),
443  [
444  'type_id' => $formTypeId,
445  'fieldset_id' => null,
446  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'postcode'),
447  'sort_order' => $elementSort++
448  ]
449  );
450  $connection->insert(
451  $this->moduleDataSetup->getTable('eav_form_element'),
452  [
453  'type_id' => $formTypeId,
454  'fieldset_id' => null,
455  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'country_id'),
456  'sort_order' => $elementSort++
457  ]
458  );
459  $connection->insert(
460  $this->moduleDataSetup->getTable('eav_form_element'),
461  [
462  'type_id' => $formTypeId,
463  'fieldset_id' => null,
464  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'telephone'),
465  'sort_order' => $elementSort++
466  ]
467  );
468  $connection->insert(
469  $this->moduleDataSetup->getTable('eav_form_element'),
470  [
471  'type_id' => $formTypeId,
472  'fieldset_id' => null,
473  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'fax'),
474  'sort_order' => $elementSort++
475  ]
476  );
477  if ($showDob) {
478  $connection->insert(
479  $this->moduleDataSetup->getTable('eav_form_element'),
480  [
481  'type_id' => $formTypeId,
482  'fieldset_id' => null,
483  'attribute_id' => $eavSetup->getAttributeId($customerEntityTypeId, 'dob'),
484  'sort_order' => $elementSort++
485  ]
486  );
487  }
488  if ($showTaxVat) {
489  $connection->insert(
490  $this->moduleDataSetup->getTable('eav_form_element'),
491  [
492  'type_id' => $formTypeId,
493  'fieldset_id' => null,
494  'attribute_id' => $eavSetup->getAttributeId($customerEntityTypeId, 'taxvat'),
495  'sort_order' => $elementSort++
496  ]
497  );
498  }
499 
506  $connection->insert(
507  $this->moduleDataSetup->getTable('eav_form_type'),
508  [
509  'code' => 'checkout_onepage_billing_address',
510  'label' => 'checkout_onepage_billing_address',
511  'is_system' => 1,
512  'theme' => '',
513  'store_id' => 0
514  ]
515  );
516  $formTypeId = $connection->lastInsertId($this->moduleDataSetup->getTable('eav_form_type'));
517 
518  $connection->insert(
519  $this->moduleDataSetup->getTable('eav_form_type_entity'),
520  ['type_id' => $formTypeId, 'entity_type_id' => $addressEntityTypeId]
521  );
522 
523  $elementSort = 0;
524  if ($showPrefix) {
525  $connection->insert(
526  $this->moduleDataSetup->getTable('eav_form_element'),
527  [
528  'type_id' => $formTypeId,
529  'fieldset_id' => null,
530  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'prefix'),
531  'sort_order' => $elementSort++
532  ]
533  );
534  }
535  $connection->insert(
536  $this->moduleDataSetup->getTable('eav_form_element'),
537  [
538  'type_id' => $formTypeId,
539  'fieldset_id' => null,
540  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'firstname'),
541  'sort_order' => $elementSort++
542  ]
543  );
544  if ($showMiddlename) {
545  $connection->insert(
546  $this->moduleDataSetup->getTable('eav_form_element'),
547  [
548  'type_id' => $formTypeId,
549  'fieldset_id' => null,
550  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'middlename'),
551  'sort_order' => $elementSort++
552  ]
553  );
554  }
555  $connection->insert(
556  $this->moduleDataSetup->getTable('eav_form_element'),
557  [
558  'type_id' => $formTypeId,
559  'fieldset_id' => null,
560  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'lastname'),
561  'sort_order' => $elementSort++
562  ]
563  );
564  if ($showSuffix) {
565  $connection->insert(
566  $this->moduleDataSetup->getTable('eav_form_element'),
567  [
568  'type_id' => $formTypeId,
569  'fieldset_id' => null,
570  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'suffix'),
571  'sort_order' => $elementSort++
572  ]
573  );
574  }
575  $connection->insert(
576  $this->moduleDataSetup->getTable('eav_form_element'),
577  [
578  'type_id' => $formTypeId,
579  'fieldset_id' => null,
580  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'company'),
581  'sort_order' => $elementSort++
582  ]
583  );
584  $connection->insert(
585  $this->moduleDataSetup->getTable('eav_form_element'),
586  [
587  'type_id' => $formTypeId,
588  'fieldset_id' => null,
589  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'street'),
590  'sort_order' => $elementSort++
591  ]
592  );
593  $connection->insert(
594  $this->moduleDataSetup->getTable('eav_form_element'),
595  [
596  'type_id' => $formTypeId,
597  'fieldset_id' => null,
598  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'city'),
599  'sort_order' => $elementSort++
600  ]
601  );
602  $connection->insert(
603  $this->moduleDataSetup->getTable('eav_form_element'),
604  [
605  'type_id' => $formTypeId,
606  'fieldset_id' => null,
607  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'region'),
608  'sort_order' => $elementSort++
609  ]
610  );
611  $connection->insert(
612  $this->moduleDataSetup->getTable('eav_form_element'),
613  [
614  'type_id' => $formTypeId,
615  'fieldset_id' => null,
616  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'postcode'),
617  'sort_order' => $elementSort++
618  ]
619  );
620  $connection->insert(
621  $this->moduleDataSetup->getTable('eav_form_element'),
622  [
623  'type_id' => $formTypeId,
624  'fieldset_id' => null,
625  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'country_id'),
626  'sort_order' => $elementSort++
627  ]
628  );
629  $connection->insert(
630  $this->moduleDataSetup->getTable('eav_form_element'),
631  [
632  'type_id' => $formTypeId,
633  'fieldset_id' => null,
634  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'telephone'),
635  'sort_order' => $elementSort++
636  ]
637  );
638  $connection->insert(
639  $this->moduleDataSetup->getTable('eav_form_element'),
640  [
641  'type_id' => $formTypeId,
642  'fieldset_id' => null,
643  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'fax'),
644  'sort_order' => $elementSort++
645  ]
646  );
647 
654  $connection->insert(
655  $this->moduleDataSetup->getTable('eav_form_type'),
656  [
657  'code' => 'checkout_onepage_shipping_address',
658  'label' => 'checkout_onepage_shipping_address',
659  'is_system' => 1,
660  'theme' => '',
661  'store_id' => 0
662  ]
663  );
664  $formTypeId = $connection->lastInsertId($this->moduleDataSetup->getTable('eav_form_type'));
665 
666  $connection->insert(
667  $this->moduleDataSetup->getTable('eav_form_type_entity'),
668  ['type_id' => $formTypeId, 'entity_type_id' => $addressEntityTypeId]
669  );
670 
671  $elementSort = 0;
672  if ($showPrefix) {
673  $connection->insert(
674  $this->moduleDataSetup->getTable('eav_form_element'),
675  [
676  'type_id' => $formTypeId,
677  'fieldset_id' => null,
678  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'prefix'),
679  'sort_order' => $elementSort++
680  ]
681  );
682  }
683  $connection->insert(
684  $this->moduleDataSetup->getTable('eav_form_element'),
685  [
686  'type_id' => $formTypeId,
687  'fieldset_id' => null,
688  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'firstname'),
689  'sort_order' => $elementSort++
690  ]
691  );
692  if ($showMiddlename) {
693  $connection->insert(
694  $this->moduleDataSetup->getTable('eav_form_element'),
695  [
696  'type_id' => $formTypeId,
697  'fieldset_id' => null,
698  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'middlename'),
699  'sort_order' => $elementSort++
700  ]
701  );
702  }
703  $connection->insert(
704  $this->moduleDataSetup->getTable('eav_form_element'),
705  [
706  'type_id' => $formTypeId,
707  'fieldset_id' => null,
708  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'lastname'),
709  'sort_order' => $elementSort++
710  ]
711  );
712  if ($showSuffix) {
713  $connection->insert(
714  $this->moduleDataSetup->getTable('eav_form_element'),
715  [
716  'type_id' => $formTypeId,
717  'fieldset_id' => null,
718  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'suffix'),
719  'sort_order' => $elementSort++
720  ]
721  );
722  }
723  $connection->insert(
724  $this->moduleDataSetup->getTable('eav_form_element'),
725  [
726  'type_id' => $formTypeId,
727  'fieldset_id' => null,
728  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'company'),
729  'sort_order' => $elementSort++
730  ]
731  );
732  $connection->insert(
733  $this->moduleDataSetup->getTable('eav_form_element'),
734  [
735  'type_id' => $formTypeId,
736  'fieldset_id' => null,
737  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'street'),
738  'sort_order' => $elementSort++
739  ]
740  );
741  $connection->insert(
742  $this->moduleDataSetup->getTable('eav_form_element'),
743  [
744  'type_id' => $formTypeId,
745  'fieldset_id' => null,
746  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'city'),
747  'sort_order' => $elementSort++
748  ]
749  );
750  $connection->insert(
751  $this->moduleDataSetup->getTable('eav_form_element'),
752  [
753  'type_id' => $formTypeId,
754  'fieldset_id' => null,
755  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'region'),
756  'sort_order' => $elementSort++
757  ]
758  );
759  $connection->insert(
760  $this->moduleDataSetup->getTable('eav_form_element'),
761  [
762  'type_id' => $formTypeId,
763  'fieldset_id' => null,
764  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'postcode'),
765  'sort_order' => $elementSort++
766  ]
767  );
768  $connection->insert(
769  $this->moduleDataSetup->getTable('eav_form_element'),
770  [
771  'type_id' => $formTypeId,
772  'fieldset_id' => null,
773  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'country_id'),
774  'sort_order' => $elementSort++
775  ]
776  );
777  $connection->insert(
778  $this->moduleDataSetup->getTable('eav_form_element'),
779  [
780  'type_id' => $formTypeId,
781  'fieldset_id' => null,
782  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'telephone'),
783  'sort_order' => $elementSort++
784  ]
785  );
786  $connection->insert(
787  $this->moduleDataSetup->getTable('eav_form_element'),
788  [
789  'type_id' => $formTypeId,
790  'fieldset_id' => null,
791  'attribute_id' => $eavSetup->getAttributeId($addressEntityTypeId, 'fax'),
792  'sort_order' => $elementSort++
793  ]
794  );
795 
796  $table = $this->moduleDataSetup->getTable('core_config_data');
797 
798  $select = $connection->select()->from(
799  $table,
800  ['config_id', 'value']
801  )->where(
802  'path = ?',
803  'checkout/options/onepage_checkout_disabled'
804  );
805 
806  $data = $connection->fetchAll($select);
807 
808  if ($data) {
809  try {
810  $connection->beginTransaction();
811 
812  foreach ($data as $value) {
813  $bind = ['path' => 'checkout/options/onepage_checkout_enabled', 'value' => !(bool)$value['value']];
814  $where = 'config_id = ' . $value['config_id'];
815  $connection->update($table, $bind, $where);
816  }
817 
818  $connection->commit();
819  } catch (\Exception $e) {
820  $connection->rollBack();
821  throw $e;
822  }
823  }
824 
825  $connection->endSetup();
826  }
827 
831  public static function getDependencies()
832  {
833  return [];
834  }
835 
839  public static function getVersion()
840  {
841  return '2.0.0';
842  }
843 
847  public function getAliases()
848  {
849  return [];
850  }
851 }
$value
Definition: gender.phtml:16
__construct(ModuleDataSetupInterface $moduleDataSetup, EavSetupFactory $eavSetupFactory, \Magento\Customer\Helper\Address $customerAddress)
$connection
Definition: bulk.php:13
$table
Definition: trigger.php:14
$customerAddress