SetNewResourceModelsPaths.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Catalog\Setup\Patch\Data;
  7. use Magento\Catalog\Setup\CategorySetup;
  8. use Magento\Catalog\Setup\CategorySetupFactory;
  9. use Magento\Framework\App\ResourceConnection;
  10. use Magento\Framework\Setup\ModuleDataSetupInterface;
  11. use Magento\Framework\Setup\Patch\DataPatchInterface;
  12. use Magento\Framework\Setup\Patch\PatchVersionInterface;
  13. /**
  14. * Class SetNewResourceModelsPaths
  15. * @package Magento\Catalog\Setup\Patch
  16. */
  17. class SetNewResourceModelsPaths implements DataPatchInterface, PatchVersionInterface
  18. {
  19. /**
  20. * @var ModuleDataSetupInterface
  21. */
  22. private $moduleDataSetup;
  23. /**
  24. * @var CategorySetupFactory
  25. */
  26. private $categorySetupFactory;
  27. /**
  28. * PatchInitial constructor.
  29. * @param ModuleDataSetupInterface $moduleDataSetup
  30. * @param CategorySetupFactory $categorySetupFactory
  31. */
  32. public function __construct(
  33. ModuleDataSetupInterface $moduleDataSetup,
  34. CategorySetupFactory $categorySetupFactory
  35. ) {
  36. $this->moduleDataSetup = $moduleDataSetup;
  37. $this->categorySetupFactory = $categorySetupFactory;
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function apply()
  43. {
  44. // set new resource model paths
  45. /** @var CategorySetup $categorySetup */
  46. $categorySetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);
  47. $categorySetup->updateEntityType(
  48. \Magento\Catalog\Model\Category::ENTITY,
  49. 'entity_model',
  50. \Magento\Catalog\Model\ResourceModel\Category::class
  51. );
  52. $categorySetup->updateEntityType(
  53. \Magento\Catalog\Model\Category::ENTITY,
  54. 'attribute_model',
  55. \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class
  56. );
  57. $categorySetup->updateEntityType(
  58. \Magento\Catalog\Model\Category::ENTITY,
  59. 'entity_attribute_collection',
  60. \Magento\Catalog\Model\ResourceModel\Category\Attribute\Collection::class
  61. );
  62. $categorySetup->updateAttribute(
  63. \Magento\Catalog\Model\Category::ENTITY,
  64. 'custom_design_from',
  65. 'attribute_model',
  66. \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class
  67. );
  68. $categorySetup->updateEntityType(
  69. \Magento\Catalog\Model\Product::ENTITY,
  70. 'entity_model',
  71. \Magento\Catalog\Model\ResourceModel\Product::class
  72. );
  73. $categorySetup->updateEntityType(
  74. \Magento\Catalog\Model\Product::ENTITY,
  75. 'attribute_model',
  76. \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class
  77. );
  78. $categorySetup->updateEntityType(
  79. \Magento\Catalog\Model\Product::ENTITY,
  80. 'entity_attribute_collection',
  81. \Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection::class
  82. );
  83. }
  84. /**
  85. * {@inheritdoc}
  86. */
  87. public static function getDependencies()
  88. {
  89. return [
  90. InstallDefaultCategories::class,
  91. ];
  92. }
  93. /**
  94. * {@inheritdoc}
  95. */
  96. public static function getVersion()
  97. {
  98. return '2.0.2';
  99. }
  100. /**
  101. * {@inheritdoc}
  102. */
  103. public function getAliases()
  104. {
  105. return [];
  106. }
  107. }