UpdateTaxClassAttributeVisibility.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Tax\Setup\Patch\Data;
  7. use Magento\Framework\App\ResourceConnection;
  8. use Magento\Framework\Setup\Patch\DataPatchInterface;
  9. use Magento\Framework\Setup\Patch\PatchVersionInterface;
  10. use Magento\Tax\Setup\TaxSetup;
  11. use Magento\Tax\Setup\TaxSetupFactory;
  12. /**
  13. * Class UpdateTaxClassAttributeVisibility
  14. * @package Magento\Tax\Setup\Patch
  15. */
  16. class UpdateTaxClassAttributeVisibility implements DataPatchInterface, PatchVersionInterface
  17. {
  18. /**
  19. * @var \Magento\Framework\Setup\ModuleDataSetupInterface
  20. */
  21. private $moduleDataSetup;
  22. /**
  23. * @var TaxSetupFactory
  24. */
  25. private $taxSetupFactory;
  26. /**
  27. * UpdateTaxClassAttributeVisibility constructor.
  28. * @param \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup
  29. * @param TaxSetupFactory $taxSetupFactory
  30. */
  31. public function __construct(
  32. \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup,
  33. TaxSetupFactory $taxSetupFactory
  34. ) {
  35. $this->moduleDataSetup = $moduleDataSetup;
  36. $this->taxSetupFactory = $taxSetupFactory;
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function apply()
  42. {
  43. /** @var TaxSetup $taxSetup */
  44. $taxSetup = $this->taxSetupFactory->create(['resourceName' => 'tax_setup', 'setup' => $this->moduleDataSetup]);
  45. $this->moduleDataSetup->getConnection()->startSetup();
  46. //Update the tax_class_id attribute in the 'catalog_eav_attribute' table
  47. $taxSetup->updateAttribute(
  48. \Magento\Catalog\Model\Product::ENTITY,
  49. 'tax_class_id',
  50. 'is_visible_in_advanced_search',
  51. false
  52. );
  53. $this->moduleDataSetup->getConnection()->endSetup();
  54. }
  55. /**
  56. * {@inheritdoc}
  57. */
  58. public static function getDependencies()
  59. {
  60. return [
  61. AddTaxAttributeAndTaxClasses::class
  62. ];
  63. }
  64. /**
  65. * {@inheritdoc}
  66. */
  67. public static function getVersion()
  68. {
  69. return '2.0.1';
  70. }
  71. /**
  72. * {@inheritdoc}
  73. */
  74. public function getAliases()
  75. {
  76. return [];
  77. }
  78. }