-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
magento 2.2 Warning: array_merge(): Argument #2 is not an array in vendor/magento/module-catalog/Helper/Product/Configuration.php on line 118 #13063
Comments
I have commented line number 118 $options = array_merge($options, $this->serializer->unserialize($addOptions->getValue())); in vendor/magento/module-catalog/Helper/Product/Configuration.php file. It is now showing cart items on cart page but the item additional options are not showing. |
So what is argument |
In the previous version i.e. 2.1.x the additional options used to using serialize and unserialize additional options. But in 2.2.x the serialize and unserialize functions are deprecated. They have created a serializer class, in that they have written json_encode() and json_decode() function. So you would need to change the code from where you add additional options. Hope this helps! |
I have checked code and found that magento 2.2 is using Magento\Framework\Serialize\Serializer\Json class function serialize and unserialize. Here json_encode is using for serialize and json_decode is using for unserialize data. use Magento\Framework\App\ObjectManager; /* add following argument to construct*/ public function execute() { $product->addCustomOption('additional_options', $this->serializer->serialize($additionalOptions)); /* Other code here*/ |
@wcldharamveer We are closing this ticket now, as it seems that you have solved the issue. |
@wcldharamveer it would be much faster to check 2.2 release notes instead of learning from code :) http://devdocs.magento.com/guides/v2.2/ext-best-practices/tutorials/serialized-to-json-data-upgrade.html |
After upgrade magento 2.1.9 to 2.2.0, I have added a product with additional_options to cart. Product is added to cart successfully but when we go to cart page it is showing Exception Warning: array_merge(): Argument #2 is not an array in vendor/magento/module-catalog/Helper/Product/Configuration.php on line 118.
My Server Details:
Error message is:
1 exception(s):
Exception #0 (Exception): Warning: array_merge(): Argument #2 is not an array in /var/www/html/motodirect/site/magento/vendor/magento/module-catalog/Helper/Product/Configuration.php on line 118
Exception #0 (Exception): Warning: array_merge(): Argument #2 is not an array in /var/www/html/motodirect/site/magento/vendor/magento/module-catalog/Helper/Product/Configuration.php on line 118
#0 [internal function]: Magento\Framework\App\ErrorHandler->handler(2, 'array_merge(): ...', '/var/www/html/m...', 118, Array)
#1 /var/www/html/motodirect/site/magento/vendor/magento/module-catalog/Helper/Product/Configuration.php(118): array_merge(Array, 'a:2:{i:0;a:2:{s...')
#2 /var/www/html/motodirect/site/magento/vendor/magento/module-catalog/Helper/Product/Configuration.php(132): Magento\Catalog\Helper\Product\Configuration->getCustomOptions(Object(Magento\Quote\Model\Quote\Item))
#3 /var/www/html/motodirect/site/magento/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Catalog\Helper\Product\Configuration->getOptions(Object(Magento\Quote\Model\Quote\Item))
#4 /var/www/html/motodirect/site/magento/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Catalog\Helper\Product\Configuration\Interceptor->___callParent('getOptions', Array)
#5 /var/www/html/motodirect/site/magento/vendor/magento/module-configurable-product/Helper/Product/Configuration/Plugin.php(32): Magento\Catalog\Helper\Product\Configuration\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Quote\Model\Quote\Item))
#6 /var/www/html/motodirect/site/magento/vendor/magento/framework/Interception/Interceptor.php(135): Magento\ConfigurableProduct\Helper\Product\Configuration\Plugin->aroundGetOptions(Object(Magento\Catalog\Helper\Product\Configuration\Interceptor), Object(Closure), Object(Magento\Quote\Model\Quote\Item))
#7 /var/www/html/motodirect/site/magento/vendor/magento/module-grouped-product/Helper/Product/Configuration/Plugin/Grouped.php(54): Magento\Catalog\Helper\Product\Configuration\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Quote\Model\Quote\Item))
#8 /var/www/html/motodirect/site/magento/vendor/magento/framework/Interception/Interceptor.php(135): Magento\GroupedProduct\Helper\Product\Configuration\Plugin\Grouped->aroundGetOptions(Object(Magento\Catalog\Helper\Product\Configuration\Interceptor), Object(Closure), Object(Magento\Quote\Model\Quote\Item))
#9 /var/www/html/motodirect/site/magento/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Catalog\Helper\Product\Configuration\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Quote\Model\Quote\Item))
#10 /var/www/html/motodirect/site/magento/generated/code/Magento/Catalog/Helper/Product/Configuration/Interceptor.php(26): Magento\Catalog\Helper\Product\Configuration\Interceptor->___callPlugins('getOptions', Array, NULL)
#11 /var/www/html/motodirect/site/magento/vendor/magento/module-checkout/Model/DefaultConfigProvider.php(404): Magento\Catalog\Helper\Product\Configuration\Interceptor->getOptions(Object(Magento\Quote\Model\Quote\Item))
#12 /var/www/html/motodirect/site/magento/vendor/magento/module-checkout/Model/DefaultConfigProvider.php(385): Magento\Checkout\Model\DefaultConfigProvider->getFormattedOptionValue(Object(Magento\Quote\Model\Quote\Item))
#13 /var/www/html/motodirect/site/magento/vendor/magento/module-checkout/Model/DefaultConfigProvider.php(257): Magento\Checkout\Model\DefaultConfigProvider->getQuoteItemData()
#14 /var/www/html/motodirect/site/magento/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Checkout\Model\DefaultConfigProvider->getConfig()
#15 /var/www/html/motodirect/site/magento/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Checkout\Model\DefaultConfigProvider\Interceptor->___callParent('getConfig', Array)
#16 /var/www/html/motodirect/site/magento/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Checkout\Model\DefaultConfigProvider\Interceptor->Magento\Framework\Interception{closure}()
#17 /var/www/html/motodirect/site/magento/generated/code/Magento/Checkout/Model/DefaultConfigProvider/Interceptor.php(26): Magento\Checkout\Model\DefaultConfigProvider\Interceptor->___callPlugins('getConfig', Array, Array)
#18 /var/www/html/motodirect/site/magento/vendor/magento/module-checkout/Model/CompositeConfigProvider.php(38): Magento\Checkout\Model\DefaultConfigProvider\Interceptor->getConfig()
#19 /var/www/html/motodirect/site/magento/vendor/magento/module-checkout/Block/Cart/Shipping.php(64): Magento\Checkout\Model\CompositeConfigProvider->getConfig()
#20 /var/www/html/motodirect/site/magento/vendor/magento/module-checkout/Block/Cart/Shipping.php(97): Magento\Checkout\Block\Cart\Shipping->getCheckoutConfig()
#21 /var/www/html/motodirect/site/magento/vendor/magento/module-checkout/view/frontend/templates/cart/shipping.phtml(28): Magento\Checkout\Block\Cart\Shipping->getSerializedCheckoutConfig()
#22 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/var/www/html/m...')
#23 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Element/Template.php(270): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\Checkout\Block\Cart\Shipping), '/var/www/html/m...', Array)
#24 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Element/Template.php(300): Magento\Framework\View\Element\Template->fetchView('/var/www/html/m...')
#25 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Element/AbstractBlock.php(667): Magento\Framework\View\Element\Template->_toHtml()
#26 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(558): Magento\Framework\View\Element\AbstractBlock->toHtml()
#27 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(534): Magento\Framework\View\Layout->_renderBlock('checkout.cart.s...')
#28 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(489): Magento\Framework\View\Layout->renderNonCachedElement('checkout.cart.s...')
#29 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\Layout->renderElement('checkout.cart.s...')
#30 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(536): Magento\Framework\View\Layout->_renderContainer('cart.summary')
#31 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(489): Magento\Framework\View\Layout->renderNonCachedElement('cart.summary')
#32 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\Layout->renderElement('cart.summary')
#33 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(536): Magento\Framework\View\Layout->_renderContainer('checkout.cart.c...')
#34 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(489): Magento\Framework\View\Layout->renderNonCachedElement('checkout.cart.c...')
#35 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\Layout->renderElement('checkout.cart.c...')
#36 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(536): Magento\Framework\View\Layout->_renderContainer('checkout.cart.i...')
#37 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(489): Magento\Framework\View\Layout->renderNonCachedElement('checkout.cart.i...')
#38 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Element/AbstractBlock.php(507): Magento\Framework\View\Layout->renderElement('checkout.cart.i...', true)
#39 /var/www/html/motodirect/site/magento/vendor/magento/module-checkout/view/frontend/templates/cart.phtml(15): Magento\Framework\View\Element\AbstractBlock->getChildHtml('with-items')
#40 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/var/www/html/m...')
#41 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Element/Template.php(270): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\Checkout\Block\Cart), '/var/www/html/m...', Array)
#42 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Element/Template.php(300): Magento\Framework\View\Element\Template->fetchView('/var/www/html/m...')
#43 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Element/AbstractBlock.php(667): Magento\Framework\View\Element\Template->_toHtml()
#44 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(558): Magento\Framework\View\Element\AbstractBlock->toHtml()
#45 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(534): Magento\Framework\View\Layout->_renderBlock('checkout.cart')
#46 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(489): Magento\Framework\View\Layout->renderNonCachedElement('checkout.cart')
#47 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\Layout->renderElement('checkout.cart')
#48 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(536): Magento\Framework\View\Layout->_renderContainer('content')
#49 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(489): Magento\Framework\View\Layout->renderNonCachedElement('content')
#50 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\Layout->renderElement('content')
#51 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(536): Magento\Framework\View\Layout->_renderContainer('main')
#52 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(489): Magento\Framework\View\Layout->renderNonCachedElement('main')
#53 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\Layout->renderElement('main')
#54 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(536): Magento\Framework\View\Layout->_renderContainer('columns')
#55 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(489): Magento\Framework\View\Layout->renderNonCachedElement('columns')
#56 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\Layout->renderElement('columns')
#57 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(536): Magento\Framework\View\Layout->_renderContainer('main.content')
#58 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(489): Magento\Framework\View\Layout->renderNonCachedElement('main.content')
#59 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\Layout->renderElement('main.content')
#60 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(536): Magento\Framework\View\Layout->_renderContainer('page.wrapper')
#61 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(489): Magento\Framework\View\Layout->renderNonCachedElement('page.wrapper')
#62 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\Layout->renderElement('page.wrapper')
#63 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(536): Magento\Framework\View\Layout->_renderContainer('root')
#64 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(489): Magento\Framework\View\Layout->renderNonCachedElement('root')
#65 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Layout.php(954): Magento\Framework\View\Layout->renderElement('root')
#66 /var/www/html/motodirect/site/magento/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\Layout->getOutput()
#67 /var/www/html/motodirect/site/magento/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\Layout\Interceptor->___callParent('getOutput', Array)
#68 /var/www/html/motodirect/site/magento/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\Layout\Interceptor->Magento\Framework\Interception{closure}()
#69 /var/www/html/motodirect/site/magento/generated/code/Magento/Framework/View/Layout/Interceptor.php(39): Magento\Framework\View\Layout\Interceptor->___callPlugins('getOutput', Array, Array)
#70 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Result/Page.php(257): Magento\Framework\View\Layout\Interceptor->getOutput()
#71 /var/www/html/motodirect/site/magento/vendor/magento/framework/View/Result/Layout.php(170): Magento\Framework\View\Result\Page->render(Object(Magento\Framework\App\Response\Http\Interceptor))
#72 /var/www/html/motodirect/site/magento/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\Result\Layout->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))
#73 /var/www/html/motodirect/site/magento/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\Result\Page\Interceptor->___callParent('renderResult', Array)
#74 /var/www/html/motodirect/site/magento/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Response\Http\Interceptor))
#75 /var/www/html/motodirect/site/magento/generated/code/Magento/Framework/View/Result/Page/Interceptor.php(39): Magento\Framework\View\Result\Page\Interceptor->___callPlugins('renderResult', Array, Array)
#76 /var/www/html/motodirect/site/magento/vendor/magento/framework/App/Http.php(139): Magento\Framework\View\Result\Page\Interceptor->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))
#77 /var/www/html/motodirect/site/magento/vendor/magento/framework/App/Bootstrap.php(256): Magento\Framework\App\Http->launch()
#78 /var/www/html/motodirect/site/magento/pub/index.php(37): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#79 {main}
The text was updated successfully, but these errors were encountered: