Skip to content

Instantly share code, notes, and snippets.

@piotrekkaminski
Created September 24, 2016 04:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piotrekkaminski/8ae3b9b353825e29948d332e31e765db to your computer and use it in GitHub Desktop.
Save piotrekkaminski/8ae3b9b353825e29948d332e31e765db to your computer and use it in GitHub Desktop.
MAGETWO-56955 [Backport] - Validation message displayed all the time - for 2.0 MAGETWO-57681 [GITHUB] Customer cannot reorder if the order has been invoiced or shipped #6278
diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Item/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Item/Collection.php
index 8872525..9fa5c8a 100644
--- a/app/code/Magento/Sales/Model/ResourceModel/Order/Item/Collection.php
+++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Item/Collection.php
@@ -55,6 +55,7 @@ protected function _afterLoad()
* Assign parent items
*/
foreach ($this as $item) {
+ $this->_resource->unserializeFields($item);
if ($item->getParentItemId()) {
$item->setParentItem($this->getItemById($item->getParentItemId()));
}
diff --git a/app/code/Magento/Theme/view/frontend/web/js/view/messages.js b/app/code/Magento/Theme/view/frontend/web/js/view/messages.js
index 2969fde..ef4fe41 100644
--- a/app/code/Magento/Theme/view/frontend/web/js/view/messages.js
+++ b/app/code/Magento/Theme/view/frontend/web/js/view/messages.js
@@ -5,9 +5,10 @@
define([
'jquery',
'uiComponent',
+ 'underscore',
'Magento_Customer/js/customer-data',
'jquery/jquery-storageapi'
-], function ($, Component, customerData) {
+], function ($, Component, _, customerData) {
'use strict';
return Component.extend({
@@ -15,12 +16,24 @@ define([
cookieMessages: [],
messages: []
},
+
+ /** @inheritdoc */
initialize: function () {
this._super();
this.cookieMessages = $.cookieStorage.get('mage-messages');
- this.messages = customerData.get('messages').extend({disposableCustomerData: 'messages'});
- $.cookieStorage.setConf({path: '/', expires: -1}).set('mage-messages', null);
+ this.messages = customerData.get('messages').extend({
+ disposableCustomerData: 'messages'
+ });
+
+ if (!_.isEmpty(this.messages().messages)) {
+ customerData.set('messages', {});
+ }
+
+ $.cookieStorage.setConf({
+ path: '/',
+ expires: -1
+ }).set('mage-messages', null);
}
});
});
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/ResourceModel/OrderItemTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/ResourceModel/OrderItemTest.php
new file mode 100644
index 0000000..e23ecd9
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Sales/Model/ResourceModel/OrderItemTest.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * Copyright © 2016 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+namespace Magento\Sales\Model\ResourceModel;
+
+class OrderItemTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @var \Magento\Framework\ObjectManagerInterface
+ */
+ private $objectManager;
+
+ protected function setUp()
+ {
+ $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
+ }
+
+ /**
+ * Verify that serialized order item data was unserialized after load
+ *
+ * @magentoDataFixture Magento/Catalog/_files/order_item_with_product_and_custom_options.php
+ */
+ public function testGetOrderItem()
+ {
+ /** @var \Magento\Sales\Model\Order $order */
+ $order = $this->objectManager->create(\Magento\Sales\Model\Order::class);
+ $order->loadByIncrementId('100000001');
+ $items = $order->getItemsCollection();
+ $this->assertNotEquals(0, $items->getSize());
+ foreach ($items as $item) {
+ $info = $item->getDataByKey('product_options');
+ $this->assertTrue(is_array($info));
+ }
+ }
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment