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.5k stars 9.3k forks source link

2.2.4 CE / PHP7.1 / NGINX Undefined index: product_id in StockManagement.php line 103 #15868

Closed QueenLinux closed 6 years ago

QueenLinux commented 6 years ago

Summary: Cannot create orders through admin panel, or frontend with guest or logged-in users.

Steps to reproduce:

  1. Clean Install of Magento CE 2.2.4, import inventory with stock control.
  2. Attempt to place order through either admin panel or frontend.
  3. See error resulting from Undefined index: product_id

Expected: Be able to make a new order.

Actual: Error shows and order is never made.

QueenLinux commented 6 years ago

Commenting for more detail:

Request after making cart and shipping: { "paymentMethod": { "method": "checkmo" }, "billing_address": { "email": "jdoe@example.com", "region": "New York", "region_id": 43, "region_code": "NY", "country_id": "US", "street": ["123 Oak Ave"], "postcode": "10577", "city": "Purchase", "telephone": "512-555-1111", "firstname": "Jane", "lastname": "Doe" } }

Response:

{ "message": "An error occurred on the server. Please try to place the order again.", "trace": "#0 /var/www/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(58): Magento\Checkout\Model\PaymentInformationManagement->savePaymentInformationAndPlaceOrder(15, Object(Magento\Quote\Model\Quote\Payment), Object(Magento\Quote\Model\Quote\Address))\n#1 /var/www/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(138): Magento\Checkout\Model\PaymentInformationManagement\Interceptor->callParent('savePaymentInfo...', Array)\n#2 /var/www/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(153): Magento\Checkout\Model\PaymentInformationManagement\Interceptor->Magento\Framework\Interception\{closure}(15, Object(Magento\Quote\Model\Quote\Payment), Object(Magento\Quote\Model\Quote\Address))\n#3 /var/www/magento2/generated/code/Magento/Checkout/Model/PaymentInformationManagement/Interceptor.php(26): Magento\Checkout\Model\PaymentInformationManagement\Interceptor->callPlugins('savePaymentInfo...', Array, Array)\n#4 [internal function]: Magento\Checkout\Model\PaymentInformationManagement\Interceptor->savePaymentInformationAndPlaceOrder(15, Object(Magento\Quote\Model\Quote\Payment), Object(Magento\Quote\Model\Quote\Address))\n#5 /var/www/magento2/app/code/Magento/Webapi/Controller/Rest.php(330): call_user_func_array(Array, Array)\n#6 /var/www/magento2/app/code/Magento/Webapi/Controller/Rest.php(239): Magento\Webapi\Controller\Rest->processApiRequest()\n#7 /var/www/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(58): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http))\n#8 /var/www/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(138): Magento\Webapi\Controller\Rest\Interceptor->callParent('dispatch', Array)\n#9 /var/www/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(153): Magento\Webapi\Controller\Rest\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#10 /var/www/magento2/generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(39): Magento\Webapi\Controller\Rest\Interceptor->callPlugins('dispatch', Array, Array)\n#11 /var/www/magento2/lib/internal/Magento/Framework/App/Http.php(135): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))\n#12 /var/www/magento2/generated/code/Magento/Framework/App/Http/Interceptor.php(24): Magento\Framework\App\Http->launch()\n#13 /var/www/magento2/lib/internal/Magento/Framework/App/Bootstrap.php(256): Magento\Framework\App\Http\Interceptor->launch()\n#14 /var/www/magento2/pub/index.php(37): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))\n#15 {main}" }

labelsdirect commented 6 years ago

I can confirm i have the same issue placing admin orders in magento 2.2.4 CE

gareth-e-james commented 6 years ago

This is the same as #15597

@mrpenelope @labelsdirect How did you create your products? I'm facing the same issue but have pinned the cause down to bad product data in the cataloginventory_stock_item table.

In the cataloginventory_stock_item table. The "website_id" column is set to "1" for products that cannot be ordered and face the issue. Changing it to 0 fixes the issue.

Also if you create a product manually through admin, then inspect the cataloginventory_stock_item table, you'll see that the new product has the website_id of 0 and can be ordered without issue.

In my case I'm talking to a 3rd party to get them to fix their module to import the data correctly.

labelsdirect commented 6 years ago

@semajeg Legend! I can confirm this was the issue.

I used the following SQL to fix the issue:

UPDATEcataloginventory_stock_itemSETwebsite_id= '0' WHEREcataloginventory_stock_item.website_id= '1'

I then retested an order through the admin and it worked.

My products were migrated from Magento 1.9 to Magento 2.2.4 using ubdata migration extension so the data must have been imported that way.

QueenLinux commented 6 years ago

This works! I guess what weirded me out is in the default sample file for inventory imports, it used "1" as the website_id for the sample items. Either way, thank you both.