0

I am having this code in template for store switcher in magento 2.3.1

 <?php
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

?>
<?php
/**
 * Language switcher template
 */
$man = \Magento\Framework\App\ObjectManager::getInstance();
$lal = $man->create('Magento\Store\ViewModel\SwitcherUrlProvider');
?>
<?php if (count($block->getStores())>1): ?>
    <?php $id = $block->getIdModifier() ? '-' . $block->getIdModifier() : ''?>
    <div class="dropdown dropdown-switcher language switcher-language" id="switcher-language<?php /* @escapeNotVerified */ echo $id?>">
        <?php foreach ($block->getStores() as $_lang): ?>
            <?php if ($_lang->getId() == $block->getCurrentStoreId()): ?>
                <button class="switcher-toggle dropdown-toggle" type="button" data-toggle="dropdown">
                    <?php echo $block->escapeHtml($_lang->getName()) ?>
                    <i class="fa fa-angle-down" aria-hidden="true"></i>
                </button>
            <?php endif; ?>
        <?php endforeach; ?>
        <ul class="dropdown-menu">
            <?php foreach ($block->getStores() as $_lang): ?>
                <?php if ($_lang->getId() != $block->getCurrentStoreId()): ?>
                    <li class="view-<?php echo $block->escapeHtml($_lang->getCode()); ?> switcher-option">
                        <a href="#" data-post='<?php /* @escapeNotVerified */ echo $block->getTargetStorePostData($_lang); ?>'>
                            <img alt="<?php echo $_lang->getCode(); ?>" src="<?php /* @escapeNotVerified */ echo $block->getViewFileUrl('images/flags/' . $_lang->getCode() . '.png') ?>" /><?php echo $block->escapeHtml($_lang->getName()) ?>
                        </a>
                    </li>
                <?php endif; ?>
            <?php endforeach; ?>
        </ul>
    </div>
<?php endif; ?>

I am not sure about this line:

<a href="#" data-post='<?php /* @escapeNotVerified */ echo $block->getTargetStorePostData($_lang); ?>'>

Because now when I hit for example English store it just refreshes the page. This is happening because when I inspect url it is only '#'

Not actual url there.

Any help please?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.