Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SetNewResourceModelsPaths.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Catalog\Setup\CategorySetupFactory;
15 
21 {
25  private $moduleDataSetup;
26 
30  private $categorySetupFactory;
31 
37  public function __construct(
38  ModuleDataSetupInterface $moduleDataSetup,
39  CategorySetupFactory $categorySetupFactory
40  ) {
41  $this->moduleDataSetup = $moduleDataSetup;
42  $this->categorySetupFactory = $categorySetupFactory;
43  }
44 
48  public function apply()
49  {
50  // set new resource model paths
52  $categorySetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);
53  $categorySetup->updateEntityType(
54  \Magento\Catalog\Model\Category::ENTITY,
55  'entity_model',
56  \Magento\Catalog\Model\ResourceModel\Category::class
57  );
58  $categorySetup->updateEntityType(
59  \Magento\Catalog\Model\Category::ENTITY,
60  'attribute_model',
61  \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class
62  );
63  $categorySetup->updateEntityType(
64  \Magento\Catalog\Model\Category::ENTITY,
65  'entity_attribute_collection',
66  \Magento\Catalog\Model\ResourceModel\Category\Attribute\Collection::class
67  );
68  $categorySetup->updateAttribute(
69  \Magento\Catalog\Model\Category::ENTITY,
70  'custom_design_from',
71  'attribute_model',
72  \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class
73  );
74  $categorySetup->updateEntityType(
75  \Magento\Catalog\Model\Product::ENTITY,
76  'entity_model',
77  \Magento\Catalog\Model\ResourceModel\Product::class
78  );
79  $categorySetup->updateEntityType(
80  \Magento\Catalog\Model\Product::ENTITY,
81  'attribute_model',
82  \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class
83  );
84  $categorySetup->updateEntityType(
85  \Magento\Catalog\Model\Product::ENTITY,
86  'entity_attribute_collection',
87  \Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection::class
88  );
89  }
90 
94  public static function getDependencies()
95  {
96  return [
97  InstallDefaultCategories::class,
98  ];
99  }
100 
104  public static function getVersion()
105  {
106  return '2.0.2';
107  }
108 
112  public function getAliases()
113  {
114  return [];
115  }
116 }
__construct(ModuleDataSetupInterface $moduleDataSetup, CategorySetupFactory $categorySetupFactory)