How to get all store url in custom phtml.

Loading...
How to get all store url in custom phtml.

In Block:

protected $_storeManager;

public function __construct(

\Magento\Store\Model\StoreManagerInterface $storeManager,

)

{

$this->_storeManager = $storeManager;

}

public function storeView()

{

$groups = $this->_storeManager->getWebsite()->getGroups();

$storeViewName = [];

foreach ($groups as $key => $group) {

$stores = $group->getStores();

foreach ($stores as $store) {

$storeViewName[] = "".$store->getName()."";

}

}

return $storeViewName;

}

In Phtml:

$stores = $block->storeView();

$allStore = implode(" ",$stores);

print_r($allStore);

?>



Copyright © 2024 Tridhya Tech Limited, Inc. All rights reserved.