protected function ContentImporter::ensureStore in Commerce Demo 8
Ensures the existence of a store.
Return value
\Drupal\commerce_store\Entity\StoreInterface The store.
1 call to ContentImporter::ensureStore()
- ContentImporter::processCommerce in src/
ContentImporter.php - Processes Commerce entity values before importing.
File
- src/
ContentImporter.php, line 312
Class
- ContentImporter
- Defines the content importer.
Namespace
Drupal\commerce_demoCode
protected function ensureStore() {
if (!$this->store) {
$store_storage = $this->entityTypeManager
->getStorage('commerce_store');
$store = $store_storage
->loadDefault();
if (!$store) {
$store = $store_storage
->create([
'type' => 'online',
'name' => 'US Store',
'mail' => 'admin@example.com',
'default_currency' => 'USD',
'address' => [
'country_code' => 'US',
'administrative_area' => 'SC',
'locality' => 'Greenville',
'postal_code' => '29616',
'address_line1' => '12344 24th St',
],
'prices_include_tax' => FALSE,
]);
$store
->save();
$store_storage
->markAsDefault($store);
}
$this->store = $store;
}
return $this->store;
}