Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Attributes
StoresFixture Class Reference
Inheritance diagram for StoresFixture:
Fixture

Public Member Functions

 __construct (FixtureModel $fixtureModel, StoreManager $storeManager, ManagerInterface $eventManager, CategoryFactory $categoryFactory, Config $localeConfig, Writer $scopeConfig)
 
 execute ()
 
 getActionTitle ()
 
 introduceParamLabels ()
 
- Public Member Functions inherited from Fixture
 __construct (FixtureModel $fixtureModel)
 
 execute ()
 
 getActionTitle ()
 
 printInfo (OutputInterface $output)
 
 introduceParamLabels ()
 
 getPriority ()
 

Data Fields

const DEFAULT_WEBSITE_COUNT = 1
 
const DEFAULT_STORE_COUNT = 1
 
const DEFAULT_STORE_VIEW_COUNT = 1
 

Protected Attributes

 $priority = 10
 
- Protected Attributes inherited from Fixture
 $priority
 
 $fixtureModel
 

Detailed Description

Generate websites, store groups and store views based on profile configuration Supports next format: <websites>{amount of websites}</websites> <store_groups>{amount of store groups}</store_groups> <store_views>{amount of store views}</store_views> <assign_entities_to_all_websites>{1|0}</assign_entities_to_all_websites>

Each node of configuration except <assign_entities_to_all_websites> means how many entities need to be generated

Store groups will have normal distribution among websites Store views will have normal distribution among store groups

<assign_entities_to_all_websites>1<assign_entities_to_all_websites> means that all stores will have the same root category

<assign_entities_to_all_websites>0<assign_entities_to_all_websites> means that all stores will have unique root category

See also
setup/performance-toolkit/profiles/ce/small.xml @SuppressWarnings(PHPMD)

Definition at line 42 of file StoresFixture.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( FixtureModel  $fixtureModel,
StoreManager  $storeManager,
ManagerInterface  $eventManager,
CategoryFactory  $categoryFactory,
Config  $localeConfig,
Writer  $scopeConfig 
)

StoresFixture constructor

Parameters
FixtureModel$fixtureModel
StoreManager$storeManager
ManagerInterface$eventManager
CategoryFactory$categoryFactory
Config$localeConfig
Writer$scopeConfig

Definition at line 159 of file StoresFixture.php.

166  {
167  parent::__construct($fixtureModel);
168  $this->storeManager = $storeManager;
169  $this->eventManager = $eventManager;
170  $this->categoryFactory = $categoryFactory;
171  $this->localeConfig = $localeConfig;
172  $this->scopeConfig = $scopeConfig;
173  }
$storeManager
$localeConfig
Definition: locales.php:13

Member Function Documentation

◆ execute()

execute ( )

{} @SuppressWarnings(PHPMD)

Definition at line 179 of file StoresFixture.php.

180  {
181  //get settings counts
182  $this->websitesCount = $this->fixtureModel->getValue('websites', self::DEFAULT_WEBSITE_COUNT);
183  $this->storeGroupsCount = $this->fixtureModel->getValue('store_groups', self::DEFAULT_STORE_COUNT);
184  $this->storesCount = $this->fixtureModel->getValue('store_views', self::DEFAULT_STORE_VIEW_COUNT);
185  $this->singleRootCategory = (bool)$this->fixtureModel->getValue('assign_entities_to_all_websites', false);
186 
187  if ($this->websitesCount <= self::DEFAULT_WEBSITE_COUNT
188  && $this->storeGroupsCount <= self::DEFAULT_STORE_COUNT
189  && $this->storesCount <= self::DEFAULT_STORE_VIEW_COUNT
190  ) {
191  return;
192  }
193 
194  //Get existing entities counts
195  $storeGroups = $this->storeManager->getGroups();
196  $this->storeGroupsIds= array_keys($storeGroups);
197 
198  foreach ($storeGroups as $storeGroupId => $storeGroup) {
199  $this->storeGroupsToWebsites[$storeGroupId] = $storeGroup->getWebsiteId();
200  }
201 
202  $this->websiteIds = array_values(array_unique($this->storeGroupsToWebsites));
203 
204  $this->defaultWebsite = $this->storeManager->getWebsite();
205  $this->defaultStoreGroup = $this->storeManager->getGroup();
206  $this->defaultWebsiteId = $this->defaultWebsite->getId();
207  $this->defaultStoreGroupId = $this->defaultStoreGroup->getId();
208  $this->defaultStoreView = $this->storeManager->getDefaultStoreView();
209  $this->storeViewIds = array_keys($this->storeManager->getStores());
210 
211  $this->generateWebsites();
212  $this->generateStoreGroups();
213  $this->generateStoreViews();
214  }

◆ getActionTitle()

getActionTitle ( )

{}

Definition at line 354 of file StoresFixture.php.

355  {
356  return 'Generating websites, stores and store views';
357  }

◆ introduceParamLabels()

introduceParamLabels ( )

{}

Definition at line 362 of file StoresFixture.php.

363  {
364  return [
365  'websites' => 'Websites',
366  'store_groups' => 'Store Groups Count',
367  'store_views' => 'Store Views Count'
368  ];
369  }

Field Documentation

◆ $priority

$priority = 10
protected

Definition at line 53 of file StoresFixture.php.

◆ DEFAULT_STORE_COUNT

const DEFAULT_STORE_COUNT = 1

Definition at line 46 of file StoresFixture.php.

◆ DEFAULT_STORE_VIEW_COUNT

const DEFAULT_STORE_VIEW_COUNT = 1

Definition at line 48 of file StoresFixture.php.

◆ DEFAULT_WEBSITE_COUNT

const DEFAULT_WEBSITE_COUNT = 1

Definition at line 44 of file StoresFixture.php.


The documentation for this class was generated from the following file: