File tree Expand file tree Collapse file tree 3 files changed +32
-3
lines changed
app/code/Magento/Sales/Model/ResourceModel/Order/Item
lib/internal/Magento/Framework/Model
ResourceModel/Db/Collection
Test/Unit/ResourceModel/Db/Collection Expand file tree Collapse file tree 3 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,6 @@ protected function _afterLoad()
55
55
* Assign parent items
56
56
*/
57
57
foreach ($ this as $ item ) {
58
- $ this ->_resource ->unserializeFields ($ item );
59
58
if ($ item ->getParentItemId ()) {
60
59
$ item ->setParentItem ($ this ->getItemById ($ item ->getParentItemId ()));
61
60
}
Original file line number Diff line number Diff line change @@ -571,8 +571,13 @@ protected function _afterLoad()
571
571
parent ::_afterLoad ();
572
572
foreach ($ this ->_items as $ item ) {
573
573
$ item ->setOrigData ();
574
- if ($ this ->_resetItemsDataChanged && ($ item instanceof \Magento \Framework \Model \AbstractModel)) {
575
- $ item ->setDataChanges (false );
574
+
575
+ if ($ item instanceof \Magento \Framework \Model \AbstractModel) {
576
+ $ this ->getResource ()->unserializeFields ($ item );
577
+
578
+ if ($ this ->_resetItemsDataChanged ) {
579
+ $ item ->setDataChanges (false );
580
+ }
576
581
}
577
582
}
578
583
$ this ->_eventManager ->dispatch ('core_collection_abstract_load_after ' , ['collection ' => $ this ]);
Original file line number Diff line number Diff line change 9
9
namespace Magento \Framework \Model \Test \Unit \ResourceModel \Db \Collection ;
10
10
11
11
use Magento \Framework \DB \Select ;
12
+ use Magento \Framework \Model \AbstractModel ;
12
13
use Magento \Framework \Model \ResourceModel \Db \Collection \AbstractCollection ;
13
14
use Magento \Framework \DataObject as MagentoObject ;
14
15
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager as ObjectManagerHelper ;
@@ -257,6 +258,30 @@ public function addFieldToSelectDataProvider()
257
258
];
258
259
}
259
260
261
+ public function testLoadWithItemFieldsUnserialization ()
262
+ {
263
+ $ itemMock = $ this ->getMockBuilder (AbstractModel::class)
264
+ ->disableOriginalConstructor ()
265
+ ->getMock ();
266
+ $ this ->uut ->addItem ($ itemMock );
267
+
268
+ $ itemMock ->expects ($ this ->once ())
269
+ ->method ('setOrigData ' );
270
+ $ this ->resourceMock ->expects ($ this ->once ())
271
+ ->method ('unserializeFields ' )
272
+ ->with ($ itemMock );
273
+
274
+ $ this ->managerMock ->expects ($ this ->exactly (2 ))
275
+ ->method ('dispatch ' )
276
+ ->withConsecutive (
277
+ ['core_collection_abstract_load_before ' , ['collection ' => $ this ->uut ]],
278
+ ['core_collection_abstract_load_after ' , ['collection ' => $ this ->uut ]]
279
+
280
+ );
281
+
282
+ $ this ->uut ->load ();
283
+ }
284
+
260
285
/**
261
286
* @dataProvider addExpressionFieldToSelectDataProvider
262
287
*/
You can’t perform that action at this time.
0 commit comments