Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while creating a creditmemo with numerical SKU #2429

Closed
HS-Fachmarkt opened this issue Jul 29, 2019 · 8 comments
Closed

Error while creating a creditmemo with numerical SKU #2429

HS-Fachmarkt opened this issue Jul 29, 2019 · 8 comments

Comments

@HS-Fachmarkt
Copy link

Preconditions (*)

  1. Magento Commerce 2.3.2 with MSI

Steps to reproduce (*)

  1. Create a product with numerical sku (123456)
  2. Order this product
  3. Create an invoice
  4. Create a credit memo

Expected result (*)

  1. Creditmemo should be created

Actual result (*)

  1. Error happens. Page is blank

AH01071: Got error 'PHP message: PHP Fatal error: Uncaught TypeError: Argument 1 passed to
Magento\InventorySales\Model\ReturnProcessor
GetInvoicedItemsPerSourceByPriority::getSourceCodeWithHighestPriorityBySku()
must be of the type string, integer given, called in
/var/www/site.pl/vendor/magento/module-inventory-sales/Model/ReturnProcessor/GetInvoicedItemsPerSourceByPriority.php
on line 121 and defined in
/var/www/site.pl/vendor/magento/module-inventory-sales/Model/ReturnProcessor/GetInvoicedItemsPerSourceByPriority.php:143

Stack trace:
#0 /var/www/site.pl/vendor/magento/module-inventory-sales/Model/ReturnProcessor/GetInvoicedItemsPerSourceByPriority.php(121): Magento\InventorySales\Model\ReturnProcessor
GetInvoicedItemsPerSourceByPriority->getSourceCodeWithHighestPriorityBySku(22344, 3)\n
#1 /var/www/site.pl/vendor/magento/module-inventory-sales/Model/ReturnProcessor/GetInvoicedItemsPerSourceByPriority.php(108...\n', referer: https://www.site.pl/admin/sales/order_creditmemo/new/key/3742f721b99fbfd664888250eb427ed557c6a049691c7381dbac67aaf696f17c/order_id/495/

grafik
This function requires the sku as string. A sku with digits only will be a integer here and leads to this error.

@smoskaluk
Copy link

smoskaluk commented Jul 29, 2019

Hi @HS-Fachmarkt! Thank you for your report, but I could not reproduce this issue. May you give more details, please? Do you have any 3-d part extensions installed?

@HS-Fachmarkt
Copy link
Author

No 3-d party extension affecting the ordermanagement installed.
Shipping and Payment are also basic ones without workflow.
My test order has products from two different sources. No default source.

@julian-van-drielen
Copy link

We're also running into the same issue on Magento 2.3.2.
Same preconditions, currently have the following temporary patch file applied since this is a blocking checkout issue for us.

---
 Model/ReturnProcessor/GetInvoicedItemsPerSourceByPriority.php | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Model/ReturnProcessor/GetInvoicedItemsPerSourceByPriority.php b/Model/ReturnProcessor/GetInvoicedItemsPerSourceByPriority.php
index e3db446..42dfd10 100644
--- a/Model/ReturnProcessor/GetInvoicedItemsPerSourceByPriority.php
+++ b/Model/ReturnProcessor/GetInvoicedItemsPerSourceByPriority.php
@@ -118,6 +118,7 @@ class GetInvoicedItemsPerSourceByPriority implements GetSourceDeductedOrderItems
         $invoicedItemsToReturn = $result = [];
         $stockId = (int)$this->stockByWebsiteIdResolver->execute($websiteId)->getStockId();
         foreach ($invoicedItems as $sku => $qty) {
+            $sku = (string) $sku;
             $sourceCode = $this->getSourceCodeWithHighestPriorityBySku($sku, $stockId);
             $invoicedItemsToReturn[$sourceCode][] = $this->sourceDeductedOrderItemFactory->create([
                 'sku' => $sku,
--
2.21.0

@klein0r
Copy link

klein0r commented Sep 27, 2019

@smoskaluk The reason is, that PHP doesn't allow numerical strings as array keys. Those are casted to integer values automatically.

Just add a cast back to string for that case (as @julianvdrielen suggested).

@ishakhsuvarov
Copy link
Contributor

@klein0r Thanks for the explanation.

It still not 100% clear how to manually reproduce the issue but I agree that service could be designed with poka-yoke in mind.

@klein0r
Copy link

klein0r commented Sep 28, 2019

@ishakhsuvarov I have that issue in my production env and also in my development env. I've requested a test instance from the magento bot, but (as you mentioned) I was not able to reproduce the issue.

But I have no idea if this inventory repository is included in those test builds. Just install 2.3.2 (not a branch) by using composer and you will be able to reproduce that behaviour.

@ebanolopes
Copy link

We are also facing same issue on the same exact conditions described on this issue.

@ishakhsuvarov
Copy link
Contributor

Closing as there is another ticket on the same matter with a proposed solution.

#2554

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants