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.31k forks source link

Magento 2.3.1 AdminOrder Illegal string offset 'options' #23384

Closed AndyJAllen closed 5 years ago

AndyJAllen commented 5 years ago

Preconditions (*)

1.Magento 2.3.1 (Upgraded from 2.2.6 with existing products)

Steps to reproduce (*)

  1. Attempt to manually create order from Admin (I tried multiple payment/shipping methods to test)

Expected result (*)

  1. Order gets created after clicking Submit Order

Actual result (*)

  1. Receive error:

Order saving error: Warning: Illegal string offset 'options' in .../vendor/magento/module-sales/Model/AdminOrder/Create.php on line 1903

image

I can place orders from the frontend just fine with the same product(s) & same customer.

m2-assistant[bot] commented 5 years ago

Hi @AndyJAllen. 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.3-develop instance - upcoming 2.3.x release

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

@AndyJAllen do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?


m2-assistant[bot] commented 5 years ago

Hi @ajijshekh123. 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:

ajijshekh123 commented 5 years ago

Give me @magento give me 2.3-develop instance

magento-engcom-team commented 5 years ago

Hi @ajijshekh123. Thank you for your request. I'm working on Magento 2.3-develop instance for you

magento-engcom-team commented 5 years ago

Hi @ajijshekh123, here is your Magento instance. Admin access: https://i-23384-2-3-develop.instances.magento-community.engineering/admin Login: admin Password: 123123q Instance will be terminated in up to 3 hours.

ajijshekh123 commented 5 years ago

Hi @AndyJAllen, In Magento 2.3 Instance, I have Placed the order using a different Payment method like.. Braintree, Check money order and Cash on delivery. See attached the screenshot:

2019-06-25 (2)

2019-06-25

2019-06-25 (1)

@AndyJAllen - Can you explain to me which payment method you using and face the error. @AndyJAllen - If this issue is not related to Default Magento Instance I will close this issue.

AndyJAllen commented 5 years ago

Hi @AndyJAllen, In Magento 2.3 Instance, I have Placed the order using a different Payment method like.. Braintree, Check money order and Cash on delivery.

@AndyJAllen - Can you explain to me which payment method you using and face the error. @AndyJAllen - If this issue is not related to Default Magento Instance I will close this issue.

I used Paypal Payflow -- but I also experienced the error with Purchase Order payment method. I did not test in vanilla instance so its possible its specific to how my instance was upgraded via composer.

AndyJAllen commented 5 years ago

I played around with the code in Create.php and got it to work by adding an isset() check. So I changed Create.php function from protected function _prepareQuoteItems() { foreach ($this->getQuote()->getAllItems() as $item) { $options = []; $productOptions = $item->getProduct()->getTypeInstance()->getOrderOptions($item->getProduct()); if ($productOptions) { $productOptions['info_buyRequest']['options'] = $this->_prepareOptionsForRequest($item); $options = $productOptions; } $addOptions = $item->getOptionByCode('additional_options'); if ($addOptions) { $options['additional_options'] = $this->serializer->unserialize($addOptions->getValue()); } $item->setProductOrderOptions($options); } return $this; }

to

protected function _prepareQuoteItems() { foreach ($this->getQuote()->getAllItems() as $item) { $options = []; $productOptions = $item->getProduct()->getTypeInstance()->getOrderOptions($item->getProduct()); if ($productOptions) { if(isset($productOptions['info_buyRequest']['options'])){ $productOptions['info_buyRequest']['options'] = $this->_prepareOptionsForRequest($item); } $options = $productOptions; } $addOptions = $item->getOptionByCode('additional_options'); if ($addOptions) { $options['additional_options'] = $this->serializer->unserialize($addOptions->getValue()); } $item->setProductOrderOptions($options); } return $this; }

engcom-Charlie commented 5 years ago

Hello @AndyJAllen ! You used custom code here , am i right ?

AndyJAllen commented 5 years ago

Hello @AndyJAllen ! You used custom code here , am i right ?

Hello Charlie,

All the code is from "magento/product-community-edition": "2.3.1" as of 5/31

I just bypassed the line of code in question to test-- the isset() addition probably doesn't make sense when attempting to set a value in this case. However it let me place the order through admin and it looks fine.

m2-assistant[bot] commented 5 years ago

Hi @engcom-Charlie. 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-Charlie commented 5 years ago

Hello @AndyJAllen ! I can`t reproduce this issue after migrating from Magento 2.2.6 to Magento 2.3.1 .

AndyJAllen commented 4 years ago

Some more information here. I'm still experiencing this on 2.3.3. I think its related to $data['info_buyRequest']

Here is what gets dropped into system.log:

`[2019-10-22 16:47:34] main.CRITICAL: Exception message: Warning: Illegal string offset 'options' in .../public_html/vendor/magento/module-sales/Model/AdminOrder/Create.php on line 1912 Trace:

#1 Magento\Sales\Model\AdminOrder\Create->_prepareQuoteItems() called at [vendor/magento/module-sales/Model/AdminOrder/Create.php:1934]

2 Magento\Sales\Model\AdminOrder\Create->createOrder() called at [vendor/magento/module-sales/Controller/Adminhtml/Order/Create/Save.php:52]

3 Magento\Sales\Controller\Adminhtml\Order\Create\Save->execute() called at [vendor/magento/framework/App/Action/Action.php:108]

4 Magento\Framework\App\Action\Action->dispatch(&Magento\Framework\App\Request\Http#000000000c8cec61000000003daea07c#) called at [vendor/magento/module-backend/App/AbstractAction.php:231]

5 Magento\Backend\App\AbstractAction->dispatch(&Magento\Framework\App\Request\Http#000000000c8cec61000000003daea07c#) called at [vendor/magento/framework/Interception/Interceptor.php:58]

6 Magento\Sales\Controller\Adminhtml\Order\Create\Save\Interceptor->___callParent('dispatch', array(&Magento\Framework\App\Request\Http#000000000c8cec61000000003daea07c#)) called at [vendor/magento/framework/Interception/Interceptor.php:138]

7 Magento\Sales\Controller\Adminhtml\Order\Create\Save\Interceptor->Magento\Framework\Interception{closure}(&Magento\Framework\App\Request\Http#000000000c8cec61000000003daea07c#) called at [vendor/magento/module-backend/App/Action/Plugin/Authentication.php:143]

8 Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(&Magento\Sales\Controller\Adminhtml\Order\Create\Save\Interceptor#000000000c8cef6d000000003daea07c#, &Closure#000000000c8cef13000000003daea07c#, &Magento\Framework\App\Request\Http#000000000c8cec61000000003daea07c#) called at [vendor/magento/framework/Interception/Interceptor.php:135]

9 Magento\Sales\Controller\Adminhtml\Order\Create\Save\Interceptor->Magento\Framework\Interception{closure}(&Magento\Framework\App\Request\Http#000000000c8cec61000000003daea07c#) called at [vendor/magento/framework/Interception/Interceptor.php:153]

10 Magento\Sales\Controller\Adminhtml\Order\Create\Save\Interceptor->___callPlugins('dispatch', array(&Magento\Framework\App\Request\Http#000000000c8cec61000000003daea07c#), NULL) called at [generated/code/Magento/Sales/Controller/Adminhtml/Order/Create/Save/Interceptor.php:26]

11 Magento\Sales\Controller\Adminhtml\Order\Create\Save\Interceptor->dispatch(&Magento\Framework\App\Request\Http#000000000c8cec61000000003daea07c#) called at [vendor/magento/framework/App/FrontController.php:159]

12 Magento\Framework\App\FrontController->processRequest(&Magento\Framework\App\Request\Http#000000000c8cec61000000003daea07c#, &Magento\Sales\Controller\Adminhtml\Order\Create\Save\Interceptor#000000000c8cef6d000000003daea07c#) called at [vendor/magento/framework/App/FrontController.php:99]

13 Magento\Framework\App\FrontController->dispatch(&Magento\Framework\App\Request\Http#000000000c8cec61000000003daea07c#) called at [vendor/magento/framework/Interception/Interceptor.php:58]

14 Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', array(&Magento\Framework\App\Request\Http#000000000c8cec61000000003daea07c#)) called at [vendor/magento/framework/Interception/Interceptor.php:138]

15 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception{closure}(&Magento\Framework\App\Request\Http#000000000c8cec61000000003daea07c#) called at [vendor/magento/framework/Interception/Interceptor.php:153]

16 Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', array(&Magento\Framework\App\Request\Http#000000000c8cec61000000003daea07c#), array(array('default_store_se...', 'page_cachefrom...', 'storeCookieValid...', 'install', 'configHash'))) called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:26]

17 Magento\Framework\App\FrontController\Interceptor->dispatch(&Magento\Framework\App\Request\Http#000000000c8cec61000000003daea07c#) called at [vendor/magento/framework/App/Http.php:137]

18 Magento\Framework\App\Http->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:24]

19 Magento\Framework\App\Http\Interceptor->launch() called at [vendor/magento/framework/App/Bootstrap.php:261]

20 Magento\Framework\App\Bootstrap->run(&Magento\Framework\App\Http\Interceptor#000000000c8cec85000000003daea07c#) called at [index.php:39]

[] []`

engcom-Charlie commented 4 years ago

Hello @AndyJAllen So could you create new issue with new steps to reproduce and additional info?

AndyJAllen commented 4 years ago

This issue stemmed from incorrect serialization of data in table sales_order_item for the field product_options. The data got out of wack and needed corrected; which I wrote a program to do.