magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

Creditmemos: The store that was requested wasn't found. Verify the store and try again. #34349

Closed jdereus87 closed 2 months ago

jdereus87 commented 3 years ago

Preconditions (*)

  1. Magento 2.4.3

Steps to reproduce (*)

  1. Change website name + storename to something that has a number. Example: '2 Unlimited'
  2. Refund an order
  3. Tab: Credit Memos now gives an error The store that was requested wasn't found. Verify the store and try again. Exception in /data/web/magento2/vendor/magento/module-store/Model/StoreRepository.php:75
  4. Menu -> Sales -> Credit Memos gives an identical error

Expected result (*)

  1. Credit memo grid Shows

Actual result (*)

  1. Credit Memo Grid gives an error.

Workaround: Remove the numbers from the store name and website name

Tested it on an existing 2.4.3 installation + a fresh 2.4.3. installation. I have processed this through xdebug.

  1. It recursively loops trough components starting in: vendor/magento/framework/View/Element/UiComponent/Context.php:255, changing values by pass by reference.
  2. Eventually it will get to the store_id component. It will run the store ID parameter through the following function: vendor/magento/module-store/Ui/Component/Listing/Column/Store.php:93 -> PrepareItem().
  3. Since the functions are all passed by reference, the data changes. The store_id value changes from a simple integer to the following: "2unlimited.nl
       2unlimited
          unlimited
    " Note: the string contains nbsp and br tags
  4. Eventually it loops to the 'subtotal' component: vendor/magento/module-sales/Ui/Component/Listing/Column/Price.php The store_id value that was changed is being used there. Function: prepareDataSource();

$storeId = isset($item['store_id']) && (int)$item['store_id'] !== 0 ? $item['store_id'] : $this->context->getFilterParam('store_id', Store::DEFAULT_STORE_ID); $store = $this->storeManager->getStore( $storeId ); Normally it gives a true & false value on the check, which causes the store_id to be set back to 0. However because there is a number in the storename (see string above), the (int) cast sets the int to 2. It now gives a true & true, and the store_id stays the strange string.

  1. In the storerepository it eventually gets to the get() function, where it fails and gives the error. vendor/magento/module-store/Model/StoreRepository.php: line 63, error on line 75.

Additional Info (*)

Note:

  1. There is no issue when Website name is given as "Unlimitted 2" (Issue raises)
  2. In 2.4-develop we can't even refund! If we try to navigate to the Credit Memo, we get the error in page loading itself. image

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

m2-assistant[bot] commented 3 years ago

Hi @jdereus87. Thank you for your report. To help us process this issue please make sure that you provided the following information:

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

:movie_camera: You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

jdereus87 commented 3 years ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 3 years ago

Hi @jdereus87. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 3 years ago

Hi @jdereus87, here is your Magento Instance: https://d49b2d3a0f4ea2fcb02ea39e7b5361f9-2-4-develop.instances.magento-community.engineering Admin access: https://d49b2d3a0f4ea2fcb02ea39e7b5361f9-2-4-develop.instances.magento-community.engineering/admin_db9d Login: eac3ff48 Password: c1c1b0d64620

jdereus87 commented 3 years ago

Bug reproduced in dev instance.

Placing a 2 on both the store name + store website directly breaks the sales -> credit memos grid with error: The store that was requested wasn't found. Verify the store and try again.

pemann commented 3 years ago

This happens also when a website/store is deleted, but creditmemos created for it are not deleted. Can be reproducted in M2.4.3+. This is the problematic commit that changed the behaviour of price formatting: https://github.com/magento/magento2/commit/bd329b681eeab9b667f2fcbe4a1aa67d23d4b3e3#diff-b21bcef0c4a13409058d73a22b1458373bf986d2ccce532d5382c96d2fb04ccb

mrtuvn commented 3 years ago

website/stores ids imho should be restrict and avoid delete. But i think core code not able handle that. Instead should expose more helpful error exception in the case we go wrong

The store that was requested wasn't found. Verify the store and try again. => Maybe add some id for able to recheck

m2-assistant[bot] commented 3 years ago

Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-November commented 3 years ago

Verified the issue on Magento 2.4-develop branch and the issue is reproducible: Steps performed: Admin - Stores - All Stores - Edit Website - Changed name to "2 Unlimitted" and Save Changed Store name to "2 Unlimitted" and Save View Sales - Credit Memos Issue; "The store that was requested wasn't found. Verify the store and try again." is displayed to the User Note: There is no issue when Website name is given as "Unlimitted 2" image

[2021-10-18T12:52:10.958580+00:00] main.CRITICAL: Magento\Framework\Exception\NoSuchEntityException: The store that was requested wasn't found. Verify the store and try again. in /var/www/html/mg24/magento2/app/code/Magento/Store/Model/StoreRepository.php:75
Stack trace:
#0 /var/www/html/mg24/magento2/app/code/Magento/Store/Model/StoreManager.php(171): Magento\Store\Model\StoreRepository->get()
#1 /var/www/html/mg24/magento2/app/code/Magento/Sales/Ui/Component/Listing/Column/Price.php(84): Magento\Store\Model\StoreManager->getStore()
#2 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php(397): Magento\Sales\Ui\Component\Listing\Column\Price->prepareDataSource()
#3 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php(394): Magento\Framework\View\Element\UiComponent\Context->prepareDataSource()
#4 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php(394): Magento\Framework\View\Element\UiComponent\Context->prepareDataSource()
#5 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php(255): Magento\Framework\View\Element\UiComponent\Context->prepareDataSource()
#6 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout/Generic.php(75): Magento\Framework\View\Element\UiComponent\Context->getDataSourceData()
#7 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout/Generator/Structure.php(46): Magento\Framework\View\Layout\Generic->build()
#8 /var/www/html/mg24/magento2/app/code/Magento/Ui/TemplateEngine/Xhtml/Result.php(102): Magento\Framework\View\Layout\Generator\Structure->generate()
#9 /var/www/html/mg24/magento2/app/code/Magento/Ui/TemplateEngine/Xhtml/Result.php(124): Magento\Ui\TemplateEngine\Xhtml\Result->appendLayoutConfiguration()
#10 /var/www/html/mg24/magento2/app/code/Magento/Ui/Component/Wrapper/UiComponent.php(73): Magento\Ui\TemplateEngine\Xhtml\Result->__toString()
#11 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Element/AbstractBlock.php(1114): Magento\Ui\Component\Wrapper\UiComponent->_toHtml()
#12 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Element/AbstractBlock.php(1118): Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element\{closure}()
#13 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Element/AbstractBlock.php(678): Magento\Framework\View\Element\AbstractBlock->_loadCache()
#14 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(591): Magento\Framework\View\Element\AbstractBlock->toHtml()
#15 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(553): Magento\Framework\View\Layout->_renderUiComponent()
#16 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(510): Magento\Framework\View\Layout->renderNonCachedElement()
#17 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(606): Magento\Framework\View\Layout->renderElement()
#18 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer()
#19 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(510): Magento\Framework\View\Layout->renderNonCachedElement()
#20 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(606): Magento\Framework\View\Layout->renderElement()
#21 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer()
#22 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(510): Magento\Framework\View\Layout->renderNonCachedElement()
#23 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(606): Magento\Framework\View\Layout->renderElement()
#24 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer()
#25 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(510): Magento\Framework\View\Layout->renderNonCachedElement()
#26 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(606): Magento\Framework\View\Layout->renderElement()
#27 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer()
#28 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(510): Magento\Framework\View\Layout->renderNonCachedElement()
#29 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(606): Magento\Framework\View\Layout->renderElement()
#30 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer()
#31 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(510): Magento\Framework\View\Layout->renderNonCachedElement()
#32 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(606): Magento\Framework\View\Layout->renderElement()
#33 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer()
#34 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(510): Magento\Framework\View\Layout->renderNonCachedElement()
#35 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(606): Magento\Framework\View\Layout->renderElement()
#36 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer()
#37 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(510): Magento\Framework\View\Layout->renderNonCachedElement()
#38 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(606): Magento\Framework\View\Layout->renderElement()
#39 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer()
#40 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(510): Magento\Framework\View\Layout->renderNonCachedElement()
#41 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Layout.php(975): Magento\Framework\View\Layout->renderElement()
#42 /var/www/html/mg24/magento2/generated/code/Magento/Framework/View/Layout/Interceptor.php(41): Magento\Framework\View\Layout->getOutput()
#43 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Result/Page.php(260): Magento\Framework\View\Layout\Interceptor->getOutput()
#44 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/View/Result/Layout.php(171): Magento\Framework\View\Result\Page->render()
#45 /var/www/html/mg24/magento2/generated/code/Magento/Backend/Model/View/Result/Page/Interceptor.php(23): Magento\Framework\View\Result\Layout->renderResult()
#46 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/App/Http.php(120): Magento\Backend\Model\View\Result\Page\Interceptor->renderResult()
#47 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/App/Bootstrap.php(264): Magento\Framework\App\Http->launch()
#48 /var/www/html/mg24/magento2/pub/index.php(30): Magento\Framework\App\Bootstrap->run()
#49 {main} [] []
github-jira-sync-bot commented 3 years ago

:white_check_mark: Jira issue https://jira.corp.magento.com/browse/AC-1508 is successfully created for this GitHub issue.

m2-assistant[bot] commented 3 years ago

:white_check_mark: Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

j-stam commented 2 years ago

Ran into the same problem yesterday. We also have digits in our website name and group name.

The problem originates from Magento/Sales/Ui/Component/Listing/Column/Price.php Line 81.

$storeId = isset($item['store_id']) && (int)$item['store_id'] !== 0 ? $item['store_id'] :
    $this->context->getFilterParam('store_id', Store::DEFAULT_STORE_ID);

adding a numeric check fixes the issue.

$storeId = isset($item['store_id']) && is_numeric($item['store_id']) && (int)$item['store_id'] !== 0
    ? $item['store_id']
    : $this->context->getFilterParam('store_id', Store::DEFAULT_STORE_ID);

I'm not sure why the data source provides the store name as the store id (probably something to do with displaying data in the grid) but because this store name string is typecasted to an integer, the digits remain and the getStore function tries to load the store with this string instead of the fallback (default store).

commit: https://github.com/magento/magento2/pull/34716/commits/5b1b00d33f6cbb8d036fd3a7b367361e303c355c

nazarklovanych commented 2 years ago

@magento I am working on this

nazarklovanych commented 2 years ago

this is already fixed in 2.4.4 @jdereus87 we can close.

eBusinessAtlantique commented 2 years ago

Where can we get the fix for M2.4.3 ? Thanks.

seungwooc-23 commented 2 years ago

Hi @jdereus87 and @nazarklovanych , we are on 2.4.4 and still experiencing this problem on the creditmemo page.

eBusinessAtlantique commented 1 year ago

When a store is deleted the credit memo grid is sending an error and do not displays. Solution : Remove these lines in this file : \vendor\magento\module-store\Model\StoreRepository.php around line 112

    if ($store->getId() === null) {
        throw new NoSuchEntityException(
            __("The store that was requested wasn't found. Verify the store and try again.")
        );
    }
simonmaass commented 9 months ago

I can confirm this issue in magento 2.4.6-p3.... i get this error when i sort the credit memo grid for the column "Credit Memo"...

image

error in response in console:

{
    "error": "The store that was requested wasn't found. Verify the store and try again.",
    "errorcode": "0"
}
roman204 commented 4 months ago

Still got this issue on 2.4.5-p6

roman204 commented 4 months ago

maybe someone can use it...

Index: vendor/magento/module-sales/Ui/Component/Listing/Column/Price.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/vendor/magento/module-sales/Ui/Component/Listing/Column/Price.php b/vendor/magento/module-sales/Ui/Component/Listing/Column/Price.php
--- a/vendor/magento/module-sales/Ui/Component/Listing/Column/Price.php
+++ b/vendor/magento/module-sales/Ui/Component/Listing/Column/Price.php (date 1719395045132)
@@ -8,6 +8,7 @@
 namespace Magento\Sales\Ui\Component\Listing\Column;

 use Magento\Framework\App\ObjectManager;
+use Magento\Framework\Exception\NoSuchEntityException;
 use Magento\Framework\View\Element\UiComponent\ContextInterface;
 use Magento\Framework\View\Element\UiComponentFactory;
 use Magento\Store\Model\Store;
@@ -82,7 +83,11 @@
                     $itemStoreId = $item['store_id'] ?? '';
                     $storeId = $itemStoreId && is_numeric($itemStoreId) ? $itemStoreId :
                         $this->context->getFilterParam('store_id', Store::DEFAULT_STORE_ID);
-                    $store = $this->storeManager->getStore($storeId);
+                    try {
+                        $store = $this->storeManager->getStore($storeId);
+                    } catch (NoSuchEntityException $entityException){
+                        $store = $this->storeManager->getStore(Store::DEFAULT_STORE_ID);
+                    }
                     $currencyCode = $store->getBaseCurrency()->getCurrencyCode();
                 }
                 $basePurchaseCurrency = $this->currency->load($currencyCode);
engcom-Bravo commented 2 months ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 2 months ago

Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 2 months ago

Hi @engcom-Bravo, here is your Magento Instance: https://b8a772eae2c727a7125f98a44a8c3222.instances-prod.magento-community.engineering Admin access: https://b8a772eae2c727a7125f98a44a8c3222.instances-prod.magento-community.engineering/admin_cb96 Login: 1241d6f4 Password: 7411c7f23672

engcom-Bravo commented 2 months ago

Hi @jdereus87,

Thanks for your reporting and collaboration.

We have verified the issue in Latest 2.4-develop instance and the issue is no more reproducible.Kindly refer the screenshots.

Screenshot 2024-09-06 at 11 04 52

Credit memo grid Shows

Hence we are closing this issue.

Thanks.