I want to create store or store view programmatically and I use the followng code (for store view):
$storeView = $objectManager->create(\Magento\Store\Model\Store::class); // Store - is a store view; Group - is a store (this is confusing)
$storeView->setName('EN');
$storeView->setCode('store2_en');
$storeView->setWebsiteId(1);
$storeView->setGroupId(2); // GroupId is a Store ID (in adminhtml terms)
$storeView->setSortOrder(10);
$storeView->setIsActive(true);
$storeView->save();
But I see in IDE that save()
method is deprecated. There is a repo for Store model (store view in adminhtml terms) - \Magento\Store\Model\StoreRepository
but this class has no save()
or create()
method (v Magento 2.1.0 RC2).
What is the right way to create store/store_views in Magento 2?
Thanks.