UpdateIdentifierCustomerAttributesVisibility.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Customer\Setup\Patch\Data;
  7. use Magento\Customer\Setup\CustomerSetupFactory;
  8. use Magento\Framework\App\ResourceConnection;
  9. use Magento\Framework\Setup\ModuleDataSetupInterface;
  10. use Magento\Framework\Setup\Patch\DataPatchInterface;
  11. use Magento\Framework\Setup\Patch\PatchVersionInterface;
  12. /**
  13. * Class UpdateIdentifierCustomerAttributesVisibility
  14. * @package Magento\Customer\Setup\Patch
  15. */
  16. class UpdateIdentifierCustomerAttributesVisibility implements DataPatchInterface, PatchVersionInterface
  17. {
  18. /**
  19. * @var ModuleDataSetupInterface
  20. */
  21. private $moduleDataSetup;
  22. /**
  23. * @var CustomerSetupFactory
  24. */
  25. private $customerSetupFactory;
  26. /**
  27. * UpdateIdentifierCustomerAttributesVisibility constructor.
  28. * @param ModuleDataSetupInterface $moduleDataSetup
  29. * @param CustomerSetupFactory $customerSetupFactory
  30. */
  31. public function __construct(
  32. ModuleDataSetupInterface $moduleDataSetup,
  33. CustomerSetupFactory $customerSetupFactory
  34. ) {
  35. $this->moduleDataSetup = $moduleDataSetup;
  36. $this->customerSetupFactory = $customerSetupFactory;
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function apply()
  42. {
  43. $customerSetup = $this->customerSetupFactory->create(['setup' => $this->moduleDataSetup]);
  44. $entityAttributes = [
  45. 'customer_address' => [
  46. 'region_id' => [
  47. 'is_used_in_grid' => false,
  48. 'is_visible_in_grid' => false,
  49. 'is_filterable_in_grid' => false,
  50. 'is_searchable_in_grid' => false,
  51. ],
  52. 'firstname' => [
  53. 'is_used_in_grid' => true,
  54. 'is_visible_in_grid' => false,
  55. 'is_filterable_in_grid' => false,
  56. 'is_searchable_in_grid' => true,
  57. ],
  58. 'lastname' => [
  59. 'is_used_in_grid' => true,
  60. 'is_visible_in_grid' => false,
  61. 'is_filterable_in_grid' => false,
  62. 'is_searchable_in_grid' => true,
  63. ],
  64. ],
  65. ];
  66. $customerSetup->upgradeAttributes($entityAttributes);
  67. }
  68. /**
  69. * {@inheritdoc}
  70. */
  71. public static function getDependencies()
  72. {
  73. return [
  74. AddNonSpecifiedGenderAttributeOption::class,
  75. ];
  76. }
  77. /**
  78. * {@inheritdoc}
  79. */
  80. public static function getVersion()
  81. {
  82. return '2.0.3';
  83. }
  84. /**
  85. * {@inheritdoc}
  86. */
  87. public function getAliases()
  88. {
  89. return [];
  90. }
  91. }