Skip to content

Commit

Permalink
#28569: Multi-store: Missing store codes in relation to a group and w…
Browse files Browse the repository at this point in the history
…ebsite

- Fixed merge conflicts with #27952
  • Loading branch information
gallyamov committed Jun 30, 2020
1 parent 2a3f775 commit d627611
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 22 deletions.
15 changes: 15 additions & 0 deletions app/code/Magento/Store/Api/Data/StoreConfigInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ public function getCode();
*/
public function setCode($code);

/**
* Get store name
*
* @return string
*/
public function getName();

/**
* Set store code
*
* @param string $name
* @return $this
*/
public function setName($name);

/**
* Get website id of the store
*
Expand Down
22 changes: 22 additions & 0 deletions app/code/Magento/Store/Model/Data/StoreConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class StoreConfig extends \Magento\Framework\Api\AbstractExtensibleObject implem
{
const KEY_ID = 'id';
const KEY_CODE = 'code';
const KEY_NAME = 'name';
const KEY_WEBSITE_ID = 'website_id';
const KEY_LOCALE = 'locale';
const KEY_BASE_CURRENCY_CODE = 'base_currency_code';
Expand Down Expand Up @@ -72,6 +73,27 @@ public function setCode($code)
return $this->setData(self::KEY_CODE, $code);
}

/**
* Get store name
*
* @return string
*/
public function getName()
{
return $this->_get(self::KEY_NAME);
}

/**
* Get store name
*
* @param string $name
* @return $this
*/
public function setName($name)
{
return $this->setData(self::KEY_NAME, $name);
}

/**
* Get website id of the store
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function getStoreByWebsiteId($websiteId)
/**
* Get website store codes
*
* @param int $websiteId
* @param string $websiteId
* @param bool $available
* @return array
*/
Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/Store/Model/Service/StoreConfigManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ protected function getStoreConfig($store)

$storeConfig->setId($store->getId())
->setCode($store->getCode())
->setWebsiteId($store->getWebsiteId());
->setWebsiteId($store->getWebsiteId())
->setName($store->getName());

foreach ($this->configPaths as $methodName => $configPath) {
$configValue = $this->scopeConfig->getValue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function getStoreConfigData(StoreInterface $store): array
* @param string $websiteId
* @return array
*/
public function getAvailableStoreConfig($websiteId): array
public function getAvailableStoreConfig(string $websiteId): array
{
$websiteStores = $this->storeWebsiteRelation->getWebsiteStoreCodes($websiteId, true);
$storeConfigs = $this->storeConfigManager->getStoreConfigs($websiteStores);
Expand Down Expand Up @@ -112,7 +112,8 @@ private function prepareStoreConfigData(StoreConfigInterface $storeConfig): arra
'secure_base_url' => $storeConfig->getSecureBaseUrl(),
'secure_base_link_url' => $storeConfig->getSecureBaseLinkUrl(),
'secure_base_static_url' => $storeConfig->getSecureBaseStaticUrl(),
'secure_base_media_url' => $storeConfig->getSecureBaseMediaUrl()
'secure_base_media_url' => $storeConfig->getSecureBaseMediaUrl(),
'store_name' => $storeConfig->getName(),
], $this->getExtendedConfigData((int)$storeConfig->getId()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,27 @@ class AvailableStoreConfigTest extends GraphQlAbstract
*/
private $objectManager;

/**
* @var StoreConfigManagerInterface
*/
private $storeConfigManager;

/**
* @inheritDoc
*/
protected function setUp(): void
{
$this->objectManager = Bootstrap::getObjectManager();
$this->storeConfigManager = $this->objectManager->get(StoreConfigManagerInterface::class);
}

/**
* @magentoApiDataFixture Magento/Store/_files/store.php
* @magentoApiDataFixture Magento/Store/_files/inactive_store.php
* @magentoConfigFixture default_store store/information/name Default Store
* @magentoConfigFixture test_store store/information/name Test Store
*/
public function testDefaultWebsiteAvailableStoreConfigs(): void
{
/** @var StoreConfigManagerInterface $storeConfigManager */
$storeConfigManager = $this->objectManager->get(StoreConfigManagerInterface::class);
$storeConfigs = $storeConfigManager->getStoreConfigs();
$storeConfigs = $this->storeConfigManager->getStoreConfigs();

$expectedAvailableStores = [];
$expectedAvailableStoreCodes = [
Expand Down Expand Up @@ -92,14 +94,10 @@ public function testDefaultWebsiteAvailableStoreConfigs(): void

/**
* @magentoApiDataFixture Magento/Store/_files/second_website_with_two_stores.php
* @magentoConfigFixture fixture_second_store_store store/information/name Fixture Second Store
* @magentoConfigFixture fixture_third_store_store store/information/name Fixture Third Store
*/
public function testNonDefaultWebsiteAvailableStoreConfigs(): void
{
/** @var StoreConfigManagerInterface $storeConfigManager */
$storeConfigManager = $this->objectManager->get(StoreConfigManagerInterface::class);
$storeConfigs = $storeConfigManager->getStoreConfigs(['fixture_second_store', 'fixture_third_store']);
$storeConfigs = $this->storeConfigManager->getStoreConfigs(['fixture_second_store', 'fixture_third_store']);

$query
= <<<QUERY
Expand Down Expand Up @@ -140,10 +138,8 @@ public function testNonDefaultWebsiteAvailableStoreConfigs(): void
* @param StoreConfigInterface $storeConfig
* @param array $responseConfig
*/
private function validateStoreConfig($storeConfig, $responseConfig): void
private function validateStoreConfig(StoreConfigInterface $storeConfig, array $responseConfig): void
{
/* @var $scopeConfig ScopeConfigInterface */
$scopeConfig = $this->objectManager->get(ScopeConfigInterface::class);
$this->assertEquals($storeConfig->getId(), $responseConfig['id']);
$this->assertEquals($storeConfig->getCode(), $responseConfig['code']);
$this->assertEquals($storeConfig->getLocale(), $responseConfig['locale']);
Expand All @@ -162,10 +158,6 @@ private function validateStoreConfig($storeConfig, $responseConfig): void
$this->assertEquals($storeConfig->getSecureBaseLinkUrl(), $responseConfig['secure_base_link_url']);
$this->assertEquals($storeConfig->getSecureBaseStaticUrl(), $responseConfig['secure_base_static_url']);
$this->assertEquals($storeConfig->getSecureBaseMediaUrl(), $responseConfig['secure_base_media_url']);
$this->assertEquals($scopeConfig->getValue(
'store/information/name',
ScopeInterface::SCOPE_STORE,
$storeConfig->getId()
), $responseConfig['store_name']);
$this->assertEquals($storeConfig->getName(), $responseConfig['store_name']);
}
}

0 comments on commit d627611

Please sign in to comment.