UpdateLinksExistDefaultAttributeValue.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\Downloadable\Setup\Patch\Data;
  8. use Magento\Eav\Setup\EavSetup;
  9. use Magento\Eav\Setup\EavSetupFactory;
  10. use Magento\Framework\Setup\ModuleDataSetupInterface;
  11. use Magento\Framework\Setup\Patch\DataPatchInterface;
  12. use Magento\Framework\Setup\Patch\PatchVersionInterface;
  13. /**
  14. * Remove default value from links exist attribute.
  15. */
  16. class UpdateLinksExistDefaultAttributeValue implements DataPatchInterface, PatchVersionInterface
  17. {
  18. /**
  19. * @var ModuleDataSetupInterface
  20. */
  21. private $moduleDataSetup;
  22. /**
  23. * @var EavSetupFactory
  24. */
  25. private $eavSetupFactory;
  26. /**
  27. * @param ModuleDataSetupInterface $moduleDataSetup
  28. * @param EavSetupFactory $eavSetupFactory
  29. */
  30. public function __construct(
  31. ModuleDataSetupInterface $moduleDataSetup,
  32. EavSetupFactory $eavSetupFactory
  33. ) {
  34. $this->moduleDataSetup = $moduleDataSetup;
  35. $this->eavSetupFactory = $eavSetupFactory;
  36. }
  37. /**
  38. * @inheritdoc
  39. */
  40. public function apply()
  41. {
  42. /** @var EavSetup $eavSetup */
  43. $eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
  44. // remove default value
  45. $eavSetup->updateAttribute(
  46. \Magento\Catalog\Model\Product::ENTITY,
  47. 'links_exist',
  48. 'default_value',
  49. null
  50. );
  51. }
  52. /**
  53. * @inheritdoc
  54. */
  55. public static function getDependencies()
  56. {
  57. return [InstallDownloadableAttributes::class];
  58. }
  59. /**
  60. * @inheritdoc
  61. */
  62. public static function getVersion()
  63. {
  64. return '2.0.3';
  65. }
  66. /**
  67. * @inheritdoc
  68. */
  69. public function getAliases()
  70. {
  71. return [];
  72. }
  73. }