File tree Expand file tree Collapse file tree 3 files changed +7
-5
lines changed Expand file tree Collapse file tree 3 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -54,12 +54,15 @@ public function copy(\Magento\Catalog\Model\Product $product)
54
54
$ product ->getWebsiteIds ();
55
55
$ product ->getCategoryIds ();
56
56
57
+ /** @var \Magento\Framework\EntityManager\EntityMetadataInterface $metadata */
58
+ $ metadata = $ this ->getMetadataPool ()->getMetadata (ProductInterface::class);
59
+
57
60
/** @var \Magento\Catalog\Model\Product $duplicate */
58
61
$ duplicate = $ this ->productFactory ->create ();
59
62
$ duplicate ->setData ($ product ->getData ());
60
63
$ duplicate ->setOptions ([]);
61
64
$ duplicate ->setIsDuplicate (true );
62
- $ duplicate ->setOriginalId ($ product ->getEntityId ( ));
65
+ $ duplicate ->setOriginalLinkId ($ product ->getData ( $ metadata -> getLinkField () ));
63
66
$ duplicate ->setStatus (\Magento \Catalog \Model \Product \Attribute \Source \Status::STATUS_DISABLED );
64
67
$ duplicate ->setCreatedAt (null );
65
68
$ duplicate ->setUpdatedAt (null );
@@ -81,7 +84,6 @@ public function copy(\Magento\Catalog\Model\Product $product)
81
84
}
82
85
} while (!$ isDuplicateSaved );
83
86
$ this ->getOptionRepository ()->duplicate ($ product , $ duplicate );
84
- $ metadata = $ this ->getMetadataPool ()->getMetadata (ProductInterface::class);
85
87
$ product ->getResource ()->duplicate (
86
88
$ product ->getData ($ metadata ->getLinkField ()),
87
89
$ duplicate ->getData ($ metadata ->getLinkField ())
Original file line number Diff line number Diff line change @@ -297,7 +297,7 @@ protected function duplicate($product)
297
297
$ this ->resourceModel ->duplicate (
298
298
$ this ->getAttribute ()->getAttributeId (),
299
299
isset ($ mediaGalleryData ['duplicate ' ]) ? $ mediaGalleryData ['duplicate ' ] : [],
300
- $ product ->getOriginalId (),
300
+ $ product ->getOriginalLinkId (),
301
301
$ product ->getData ($ this ->metadata ->getLinkField ())
302
302
);
303
303
Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ public function testCopy()
98
98
'setOptions ' ,
99
99
'getData ' ,
100
100
'setIsDuplicate ' ,
101
- 'setOriginalId ' ,
101
+ 'setOriginalLinkId ' ,
102
102
'setStatus ' ,
103
103
'setCreatedAt ' ,
104
104
'setUpdatedAt ' ,
@@ -117,7 +117,7 @@ public function testCopy()
117
117
118
118
$ duplicateMock ->expects ($ this ->once ())->method ('setOptions ' )->with ([]);
119
119
$ duplicateMock ->expects ($ this ->once ())->method ('setIsDuplicate ' )->with (true );
120
- $ duplicateMock ->expects ($ this ->once ())->method ('setOriginalId ' )->with (1 );
120
+ $ duplicateMock ->expects ($ this ->once ())->method ('setOriginalLinkId ' )->with (1 );
121
121
$ duplicateMock ->expects (
122
122
$ this ->once ()
123
123
)->method (
You can’t perform that action at this time.
0 commit comments