KaMZaTa
KaMZaTa

Reputation: 741

Magento 2: “The store that was requested wasn't found. Verify the store and try again.”

Everytime I'm switching from the English store view to the Italian's one and viceversa, it takes me to the equivalent homepage (no matters where I am) and it throws this error:

The store that was requested wasn't found. Verify the store and try again.

Here's my setup:

Recap: If, for example, I'm on example.com/my-beautiful-product.html [English store view] and I'm switching to the Italian store view, it takes me to example.it and it shows that error ("The store that was requested wasn't found. Verify the store and try again.") instead of take me on example.it/my-beautiful-product.html without any errors.

Any Ideas?


What I tested:

Then I switched from Italian store view to the English one and it worked! So it seems it does not able to get the correct values of $targetStoreCode, and $requestedUrlToRedirect. Any ideas?

Upvotes: 3

Views: 21921

Answers (4)

Gerard de Visser
Gerard de Visser

Reputation: 8050

The issue can also be that the database table core_config_data is containing records for a store view that doesn't exist (anymore).

In this case, removing this records manually will resolve the error.

Upvotes: 0

Kalif Mihai
Kalif Mihai

Reputation: 1

Make sure the tables from the databasese don't have soft_ in the name. I had to modify all the table to match the descriptions: alter table soft_adminnotification_inbox rename to adminnotification_inbox .. .. ..

Upvotes: 0

Robert Łoziński
Robert Łoziński

Reputation: 79

Please try to clear all data from table "flag".

Upvotes: 0

KaMZaTa
KaMZaTa

Reputation: 741

It's a Magento 2.3.1 to 2.3.5 bug. The problem is in the view... and exactly in module-store/view/frontend/templates/switch/languages.phtml at the line 28.

WRONG

<li class="view-<?= $block->escapeHtml($_lang->getCode()) ?> switcher-option">
    <a href="<?= $block->escapeUrl($block->getViewModel()->getTargetStoreRedirectUrl($_lang)) ?>">
        <?= $block->escapeHtml($_lang->getName()) ?>
    </a>
</li>

CORRECT

<li class="view-<?= $block->escapeHtml($_lang->getCode()) ?> switcher-option">
    <a href="#" data-post='<?= /* @noEscape */ $block->getTargetStorePostData($_lang) ?>'>
        <?= $block->escapeHtml($_lang->getName()) ?>
    </a>
</li>

...and now it works like a charm!

Upvotes: 3

Related Questions