Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
websites_different_countries_rollback.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
14 
15 $objectManager = Bootstrap::getObjectManager();
17 $registry = $objectManager->get(Registry::class);
18 $registry->unregister('isSecureArea');
19 $registry->register('isSecureArea', true);
20 
21 //Deleting second website's store.
22 $store = $objectManager->create(Store::class);
23 if ($store->load('fixture_second_store', 'code')->getId()) {
24  $store->delete();
25 }
26 
27 //Deleting the second website.
28 
29 $configResource = $objectManager->get(\Magento\Config\Model\ResourceModel\Config::class);
30 //Restoring allowed countries.
31 $configResource->deleteConfig(
32  'general/country/allow',
33  \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITES,
34  1
35 );
37 $website = $objectManager->create(Website::class);
38 $website->load('test');
39 if ($website->getId()) {
40  $configResource->deleteConfig(
41  'general/country/allow',
42  \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITES,
43  $website->getId()
44  );
45  $website->delete();
46 }
47 $registry->unregister('isSecureArea');
48 $registry->register('isSecureArea', false);
49 
50 /* Refresh stores memory cache */
52 $storeManager = $objectManager->get(\Magento\Store\Model\StoreManagerInterface::class);
53 $storeManager->reinitStores();
54 /* Refresh CatalogSearch index */
56 $indexerRegistry = $objectManager->create(\Magento\Framework\Indexer\IndexerRegistry::class);
57 $indexerRegistry->get(FulltextIndex::INDEXER_ID)->reindexAll();
58 //Clear config cache.
59 $objectManager->get(ReinitableConfigInterface::class)->reinit();
if($store->load('fixture_second_store', 'code') ->getId()) $configResource