10 use Magento\Eav\Setup\EavSetupFactory;
25 private $moduleDataSetup;
30 private $eavSetupFactory;
35 private $customerAddress;
43 EavSetupFactory $eavSetupFactory,
44 \
Magento\Customer\Helper\Address $customerAddress
46 $this->moduleDataSetup = $moduleDataSetup;
57 public function apply()
60 $eavSetup = $this->eavSetupFactory->create([
'setup' => $this->moduleDataSetup]);
62 $this->moduleDataSetup->getConnection()->startSetup();
64 $connection = $this->moduleDataSetup->getConnection();
67 $this->moduleDataSetup->getTable(
'core_config_data'),
71 'customer/address/prefix_show' 76 $showPrefix = (bool)$this->customerAddress->getConfig(
'prefix_show')
80 $this->moduleDataSetup->getTable(
'core_config_data'),
84 'customer/address/middlename_show' 89 $showMiddlename = (bool)$this->customerAddress->getConfig(
'middlename_show')
93 $this->moduleDataSetup->getTable(
'core_config_data'),
97 'customer/address/suffix_show' 102 $showSuffix = (bool)$this->customerAddress->getConfig(
'suffix_show')
106 $this->moduleDataSetup->getTable(
'core_config_data'),
110 'customer/address/dob_show' 115 $showDob = (bool)$this->customerAddress->getConfig(
'dob_show')
119 $this->moduleDataSetup->getTable(
'core_config_data'),
123 'customer/address/taxvat_show' 128 $showTaxVat = (bool)$this->customerAddress->getConfig(
'taxvat_show')
131 $customerEntityTypeId =
$eavSetup->getEntityTypeId(
'customer');
132 $addressEntityTypeId =
$eavSetup->getEntityTypeId(
'customer_address');
141 $this->moduleDataSetup->getTable(
'eav_form_type'),
143 'code' =>
'checkout_onepage_register',
144 'label' =>
'checkout_onepage_register',
150 $formTypeId =
$connection->lastInsertId($this->moduleDataSetup->getTable(
'eav_form_type'));
153 $this->moduleDataSetup->getTable(
'eav_form_type_entity'),
154 [
'type_id' => $formTypeId,
'entity_type_id' => $customerEntityTypeId]
157 $this->moduleDataSetup->getTable(
'eav_form_type_entity'),
158 [
'type_id' => $formTypeId,
'entity_type_id' => $addressEntityTypeId]
164 $this->moduleDataSetup->getTable(
'eav_form_element'),
166 'type_id' => $formTypeId,
167 'fieldset_id' =>
null,
168 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'prefix'),
169 'sort_order' => $elementSort++
174 $this->moduleDataSetup->getTable(
'eav_form_element'),
176 'type_id' => $formTypeId,
177 'fieldset_id' =>
null,
178 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'firstname'),
179 'sort_order' => $elementSort++
182 if ($showMiddlename) {
184 $this->moduleDataSetup->getTable(
'eav_form_element'),
186 'type_id' => $formTypeId,
187 'fieldset_id' =>
null,
188 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'middlename'),
189 'sort_order' => $elementSort++
194 $this->moduleDataSetup->getTable(
'eav_form_element'),
196 'type_id' => $formTypeId,
197 'fieldset_id' =>
null,
198 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'lastname'),
199 'sort_order' => $elementSort++
204 $this->moduleDataSetup->getTable(
'eav_form_element'),
206 'type_id' => $formTypeId,
207 'fieldset_id' =>
null,
208 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'suffix'),
209 'sort_order' => $elementSort++
214 $this->moduleDataSetup->getTable(
'eav_form_element'),
216 'type_id' => $formTypeId,
217 'fieldset_id' =>
null,
218 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'company'),
219 'sort_order' => $elementSort++
223 $this->moduleDataSetup->getTable(
'eav_form_element'),
225 'type_id' => $formTypeId,
226 'fieldset_id' =>
null,
227 'attribute_id' =>
$eavSetup->getAttributeId($customerEntityTypeId,
'email'),
228 'sort_order' => $elementSort++
232 $this->moduleDataSetup->getTable(
'eav_form_element'),
234 'type_id' => $formTypeId,
235 'fieldset_id' =>
null,
236 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'street'),
237 'sort_order' => $elementSort++
241 $this->moduleDataSetup->getTable(
'eav_form_element'),
243 'type_id' => $formTypeId,
244 'fieldset_id' =>
null,
245 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'city'),
246 'sort_order' => $elementSort++
250 $this->moduleDataSetup->getTable(
'eav_form_element'),
252 'type_id' => $formTypeId,
253 'fieldset_id' =>
null,
254 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'region'),
255 'sort_order' => $elementSort++
259 $this->moduleDataSetup->getTable(
'eav_form_element'),
261 'type_id' => $formTypeId,
262 'fieldset_id' =>
null,
263 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'postcode'),
264 'sort_order' => $elementSort++
268 $this->moduleDataSetup->getTable(
'eav_form_element'),
270 'type_id' => $formTypeId,
271 'fieldset_id' =>
null,
272 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'country_id'),
273 'sort_order' => $elementSort++
277 $this->moduleDataSetup->getTable(
'eav_form_element'),
279 'type_id' => $formTypeId,
280 'fieldset_id' =>
null,
281 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'telephone'),
282 'sort_order' => $elementSort++
286 $this->moduleDataSetup->getTable(
'eav_form_element'),
288 'type_id' => $formTypeId,
289 'fieldset_id' =>
null,
290 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'fax'),
291 'sort_order' => $elementSort++
296 $this->moduleDataSetup->getTable(
'eav_form_element'),
298 'type_id' => $formTypeId,
299 'fieldset_id' =>
null,
300 'attribute_id' =>
$eavSetup->getAttributeId($customerEntityTypeId,
'dob'),
301 'sort_order' => $elementSort++
307 $this->moduleDataSetup->getTable(
'eav_form_element'),
309 'type_id' => $formTypeId,
310 'fieldset_id' =>
null,
311 'attribute_id' =>
$eavSetup->getAttributeId($customerEntityTypeId,
'taxvat'),
312 'sort_order' => $elementSort++
324 $this->moduleDataSetup->getTable(
'eav_form_type'),
326 'code' =>
'checkout_onepage_register_guest',
327 'label' =>
'checkout_onepage_register_guest',
333 $formTypeId =
$connection->lastInsertId($this->moduleDataSetup->getTable(
'eav_form_type'));
336 $this->moduleDataSetup->getTable(
'eav_form_type_entity'),
337 [
'type_id' => $formTypeId,
'entity_type_id' => $customerEntityTypeId]
340 $this->moduleDataSetup->getTable(
'eav_form_type_entity'),
341 [
'type_id' => $formTypeId,
'entity_type_id' => $addressEntityTypeId]
347 $this->moduleDataSetup->getTable(
'eav_form_element'),
349 'type_id' => $formTypeId,
350 'fieldset_id' =>
null,
351 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'prefix'),
352 'sort_order' => $elementSort++
357 $this->moduleDataSetup->getTable(
'eav_form_element'),
359 'type_id' => $formTypeId,
360 'fieldset_id' =>
null,
361 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'firstname'),
362 'sort_order' => $elementSort++
365 if ($showMiddlename) {
367 $this->moduleDataSetup->getTable(
'eav_form_element'),
369 'type_id' => $formTypeId,
370 'fieldset_id' =>
null,
371 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'middlename'),
372 'sort_order' => $elementSort++
377 $this->moduleDataSetup->getTable(
'eav_form_element'),
379 'type_id' => $formTypeId,
380 'fieldset_id' =>
null,
381 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'lastname'),
382 'sort_order' => $elementSort++
387 $this->moduleDataSetup->getTable(
'eav_form_element'),
389 'type_id' => $formTypeId,
390 'fieldset_id' =>
null,
391 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'suffix'),
392 'sort_order' => $elementSort++
397 $this->moduleDataSetup->getTable(
'eav_form_element'),
399 'type_id' => $formTypeId,
400 'fieldset_id' =>
null,
401 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'company'),
402 'sort_order' => $elementSort++
406 $this->moduleDataSetup->getTable(
'eav_form_element'),
408 'type_id' => $formTypeId,
409 'fieldset_id' =>
null,
410 'attribute_id' =>
$eavSetup->getAttributeId($customerEntityTypeId,
'email'),
411 'sort_order' => $elementSort++
415 $this->moduleDataSetup->getTable(
'eav_form_element'),
417 'type_id' => $formTypeId,
418 'fieldset_id' =>
null,
419 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'street'),
420 'sort_order' => $elementSort++
424 $this->moduleDataSetup->getTable(
'eav_form_element'),
426 'type_id' => $formTypeId,
427 'fieldset_id' =>
null,
428 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'city'),
429 'sort_order' => $elementSort++
433 $this->moduleDataSetup->getTable(
'eav_form_element'),
435 'type_id' => $formTypeId,
436 'fieldset_id' =>
null,
437 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'region'),
438 'sort_order' => $elementSort++
442 $this->moduleDataSetup->getTable(
'eav_form_element'),
444 'type_id' => $formTypeId,
445 'fieldset_id' =>
null,
446 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'postcode'),
447 'sort_order' => $elementSort++
451 $this->moduleDataSetup->getTable(
'eav_form_element'),
453 'type_id' => $formTypeId,
454 'fieldset_id' =>
null,
455 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'country_id'),
456 'sort_order' => $elementSort++
460 $this->moduleDataSetup->getTable(
'eav_form_element'),
462 'type_id' => $formTypeId,
463 'fieldset_id' =>
null,
464 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'telephone'),
465 'sort_order' => $elementSort++
469 $this->moduleDataSetup->getTable(
'eav_form_element'),
471 'type_id' => $formTypeId,
472 'fieldset_id' =>
null,
473 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'fax'),
474 'sort_order' => $elementSort++
479 $this->moduleDataSetup->getTable(
'eav_form_element'),
481 'type_id' => $formTypeId,
482 'fieldset_id' =>
null,
483 'attribute_id' =>
$eavSetup->getAttributeId($customerEntityTypeId,
'dob'),
484 'sort_order' => $elementSort++
490 $this->moduleDataSetup->getTable(
'eav_form_element'),
492 'type_id' => $formTypeId,
493 'fieldset_id' =>
null,
494 'attribute_id' =>
$eavSetup->getAttributeId($customerEntityTypeId,
'taxvat'),
495 'sort_order' => $elementSort++
507 $this->moduleDataSetup->getTable(
'eav_form_type'),
509 'code' =>
'checkout_onepage_billing_address',
510 'label' =>
'checkout_onepage_billing_address',
516 $formTypeId =
$connection->lastInsertId($this->moduleDataSetup->getTable(
'eav_form_type'));
519 $this->moduleDataSetup->getTable(
'eav_form_type_entity'),
520 [
'type_id' => $formTypeId,
'entity_type_id' => $addressEntityTypeId]
526 $this->moduleDataSetup->getTable(
'eav_form_element'),
528 'type_id' => $formTypeId,
529 'fieldset_id' =>
null,
530 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'prefix'),
531 'sort_order' => $elementSort++
536 $this->moduleDataSetup->getTable(
'eav_form_element'),
538 'type_id' => $formTypeId,
539 'fieldset_id' =>
null,
540 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'firstname'),
541 'sort_order' => $elementSort++
544 if ($showMiddlename) {
546 $this->moduleDataSetup->getTable(
'eav_form_element'),
548 'type_id' => $formTypeId,
549 'fieldset_id' =>
null,
550 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'middlename'),
551 'sort_order' => $elementSort++
556 $this->moduleDataSetup->getTable(
'eav_form_element'),
558 'type_id' => $formTypeId,
559 'fieldset_id' =>
null,
560 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'lastname'),
561 'sort_order' => $elementSort++
566 $this->moduleDataSetup->getTable(
'eav_form_element'),
568 'type_id' => $formTypeId,
569 'fieldset_id' =>
null,
570 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'suffix'),
571 'sort_order' => $elementSort++
576 $this->moduleDataSetup->getTable(
'eav_form_element'),
578 'type_id' => $formTypeId,
579 'fieldset_id' =>
null,
580 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'company'),
581 'sort_order' => $elementSort++
585 $this->moduleDataSetup->getTable(
'eav_form_element'),
587 'type_id' => $formTypeId,
588 'fieldset_id' =>
null,
589 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'street'),
590 'sort_order' => $elementSort++
594 $this->moduleDataSetup->getTable(
'eav_form_element'),
596 'type_id' => $formTypeId,
597 'fieldset_id' =>
null,
598 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'city'),
599 'sort_order' => $elementSort++
603 $this->moduleDataSetup->getTable(
'eav_form_element'),
605 'type_id' => $formTypeId,
606 'fieldset_id' =>
null,
607 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'region'),
608 'sort_order' => $elementSort++
612 $this->moduleDataSetup->getTable(
'eav_form_element'),
614 'type_id' => $formTypeId,
615 'fieldset_id' =>
null,
616 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'postcode'),
617 'sort_order' => $elementSort++
621 $this->moduleDataSetup->getTable(
'eav_form_element'),
623 'type_id' => $formTypeId,
624 'fieldset_id' =>
null,
625 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'country_id'),
626 'sort_order' => $elementSort++
630 $this->moduleDataSetup->getTable(
'eav_form_element'),
632 'type_id' => $formTypeId,
633 'fieldset_id' =>
null,
634 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'telephone'),
635 'sort_order' => $elementSort++
639 $this->moduleDataSetup->getTable(
'eav_form_element'),
641 'type_id' => $formTypeId,
642 'fieldset_id' =>
null,
643 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'fax'),
644 'sort_order' => $elementSort++
655 $this->moduleDataSetup->getTable(
'eav_form_type'),
657 'code' =>
'checkout_onepage_shipping_address',
658 'label' =>
'checkout_onepage_shipping_address',
664 $formTypeId =
$connection->lastInsertId($this->moduleDataSetup->getTable(
'eav_form_type'));
667 $this->moduleDataSetup->getTable(
'eav_form_type_entity'),
668 [
'type_id' => $formTypeId,
'entity_type_id' => $addressEntityTypeId]
674 $this->moduleDataSetup->getTable(
'eav_form_element'),
676 'type_id' => $formTypeId,
677 'fieldset_id' =>
null,
678 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'prefix'),
679 'sort_order' => $elementSort++
684 $this->moduleDataSetup->getTable(
'eav_form_element'),
686 'type_id' => $formTypeId,
687 'fieldset_id' =>
null,
688 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'firstname'),
689 'sort_order' => $elementSort++
692 if ($showMiddlename) {
694 $this->moduleDataSetup->getTable(
'eav_form_element'),
696 'type_id' => $formTypeId,
697 'fieldset_id' =>
null,
698 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'middlename'),
699 'sort_order' => $elementSort++
704 $this->moduleDataSetup->getTable(
'eav_form_element'),
706 'type_id' => $formTypeId,
707 'fieldset_id' =>
null,
708 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'lastname'),
709 'sort_order' => $elementSort++
714 $this->moduleDataSetup->getTable(
'eav_form_element'),
716 'type_id' => $formTypeId,
717 'fieldset_id' =>
null,
718 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'suffix'),
719 'sort_order' => $elementSort++
724 $this->moduleDataSetup->getTable(
'eav_form_element'),
726 'type_id' => $formTypeId,
727 'fieldset_id' =>
null,
728 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'company'),
729 'sort_order' => $elementSort++
733 $this->moduleDataSetup->getTable(
'eav_form_element'),
735 'type_id' => $formTypeId,
736 'fieldset_id' =>
null,
737 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'street'),
738 'sort_order' => $elementSort++
742 $this->moduleDataSetup->getTable(
'eav_form_element'),
744 'type_id' => $formTypeId,
745 'fieldset_id' =>
null,
746 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'city'),
747 'sort_order' => $elementSort++
751 $this->moduleDataSetup->getTable(
'eav_form_element'),
753 'type_id' => $formTypeId,
754 'fieldset_id' =>
null,
755 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'region'),
756 'sort_order' => $elementSort++
760 $this->moduleDataSetup->getTable(
'eav_form_element'),
762 'type_id' => $formTypeId,
763 'fieldset_id' =>
null,
764 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'postcode'),
765 'sort_order' => $elementSort++
769 $this->moduleDataSetup->getTable(
'eav_form_element'),
771 'type_id' => $formTypeId,
772 'fieldset_id' =>
null,
773 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'country_id'),
774 'sort_order' => $elementSort++
778 $this->moduleDataSetup->getTable(
'eav_form_element'),
780 'type_id' => $formTypeId,
781 'fieldset_id' =>
null,
782 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'telephone'),
783 'sort_order' => $elementSort++
787 $this->moduleDataSetup->getTable(
'eav_form_element'),
789 'type_id' => $formTypeId,
790 'fieldset_id' =>
null,
791 'attribute_id' =>
$eavSetup->getAttributeId($addressEntityTypeId,
'fax'),
792 'sort_order' => $elementSort++
796 $table = $this->moduleDataSetup->getTable(
'core_config_data');
800 [
'config_id',
'value']
803 'checkout/options/onepage_checkout_disabled' 813 $bind = [
'path' =>
'checkout/options/onepage_checkout_enabled',
'value' => !(bool)
$value[
'value']];
814 $where =
'config_id = ' .
$value[
'config_id'];
819 }
catch (\Exception $e) {
__construct(ModuleDataSetupInterface $moduleDataSetup, EavSetupFactory $eavSetupFactory, \Magento\Customer\Helper\Address $customerAddress)