Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
EnableSegmentation.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
8 
11 
18 {
22  private $schemaSetup;
23 
29  public function __construct(
30  SchemaSetupInterface $schemaSetup
31  ) {
32  $this->schemaSetup = $schemaSetup;
33  }
34 
38  public function apply()
39  {
40  $this->schemaSetup->startSetup();
41  $setup = $this->schemaSetup;
42 
43  $storeSelect = $setup->getConnection()->select()->from($setup->getTable('store'))->where('store_id > 0');
44  foreach ($setup->getConnection()->fetchAll($storeSelect) as $store) {
45  $indexTable = $setup->getTable('catalog_category_product_index') .
46  '_' .
48  $store['store_id'];
49  if (!$setup->getConnection()->isTableExists($indexTable)) {
50  $setup->getConnection()->createTable(
51  $setup->getConnection()->createTableByDdl(
52  $setup->getTable('catalog_category_product_index'),
53  $indexTable
54  )
55  );
56  }
57  if (!$setup->getConnection()->isTableExists($indexTable . '_replica')) {
58  $setup->getConnection()->createTable(
59  $setup->getConnection()->createTableByDdl(
60  $setup->getTable('catalog_category_product_index'),
61  $indexTable . '_replica'
62  )
63  );
64  }
65  }
66 
67  $this->schemaSetup->endSetup();
68  }
69 
73  public static function getDependencies()
74  {
75  return [];
76  }
77 
81  public function getAliases()
82  {
83  return [];
84  }
85 }
$setup
Definition: trigger.php:12