File tree Expand file tree Collapse file tree 4 files changed +24
-11
lines changed
Controller/Adminhtml/Product/Initialization
Controller/Adminhtml/Product/Initialization Expand file tree Collapse file tree 4 files changed +24
-11
lines changed Original file line number Diff line number Diff line change @@ -202,6 +202,7 @@ public function initialize(\Magento\Catalog\Model\Product $product)
202
202
}
203
203
204
204
/**
205
+ * @deprecated
205
206
* @return LinkResolver
206
207
*/
207
208
private function getLinkResolver ()
Original file line number Diff line number Diff line change @@ -32,15 +32,17 @@ protected function indexBySku(array $products)
32
32
public function convertLinksToGroupedArray ($ entity )
33
33
{
34
34
$ basicData = $ entity ->getProductLinks ();
35
- $ additionalData = $ entity ->getTypeInstance ()->getAssociatedProducts ($ entity );
36
- $ additionalData = $ this ->indexBySku ($ additionalData );
35
+ $ associatedProducts = $ entity ->getTypeInstance ()->getAssociatedProducts ($ entity );
36
+ $ associatedProducts = $ this ->indexBySku ($ associatedProducts );
37
37
38
38
/** @var \Magento\Catalog\Api\Data\ProductLinkInterface $link */
39
39
foreach ($ basicData as $ link ) {
40
- $ info = [];
41
- $ info ['id ' ] = $ additionalData [$ link ->getLinkedProductSku ()]->getId ();
42
- $ info ['sku ' ] = $ link ->getLinkedProductSku ();
43
- $ info ['position ' ] = $ link ->getPosition ();
40
+ $ info = $ link ->getData ();
41
+ if ($ link ->getLinkType () == 'associated ' ) {
42
+ $ info ['id ' ] = $ associatedProducts [$ link ->getLinkedProductSku ()]->getId ();
43
+ }
44
+ // $info['sku'] = $link->getLinkedProductSku();
45
+ // $info['position'] = $link->getPosition();
44
46
$ info = array_merge ($ info , $ link ->getExtensionAttributes ()->__toArray ());
45
47
$ linksAsArray [$ link ->getLinkType ()][] = $ info ;
46
48
}
Original file line number Diff line number Diff line change @@ -96,6 +96,11 @@ class HelperTest extends \PHPUnit_Framework_TestCase
96
96
*/
97
97
protected $ customOptionMock ;
98
98
99
+ /**
100
+ * @var \PHPUnit_Framework_MockObject_MockObject
101
+ */
102
+ protected $ linkResolverMock ;
103
+
99
104
/**
100
105
* @var ProductLinks
101
106
*/
@@ -175,6 +180,14 @@ protected function setUp()
175
180
'productLinkFactory ' => $ this ->productLinkFactoryMock ,
176
181
'productRepository ' => $ this ->productRepositoryMock ,
177
182
]);
183
+
184
+ $ this ->linkResolverMock = $ this ->getMockBuilder (\Magento \Catalog \Model \Product \Link \Resolver::class)
185
+ ->disableOriginalConstructor ()
186
+ ->getMock ();
187
+ $ helperReflection = new \ReflectionClass (get_class ($ this ->helper ));
188
+ $ resolverProperty = $ helperReflection ->getProperty ('linkResolver ' );
189
+ $ resolverProperty ->setAccessible (true );
190
+ $ resolverProperty ->setValue ($ this ->helper , $ this ->linkResolverMock );
178
191
}
179
192
180
193
/**
@@ -248,10 +261,7 @@ public function testInitialize()
248
261
->method ('getPost ' )
249
262
->with ('use_default ' )
250
263
->willReturn ($ useDefaults );
251
- $ this ->requestMock ->expects ($ this ->at (3 ))
252
- ->method ('getPost ' )
253
- ->with ('options_use_default ' )
254
- ->willReturn (true );
264
+ $ this ->linkResolverMock ->expects ($ this ->once ())->method ('getLinks ' )->willReturn ([]);
255
265
$ this ->stockFilterMock ->expects ($ this ->once ())
256
266
->method ('filter ' )
257
267
->with (['stock_data ' ])
Original file line number Diff line number Diff line change @@ -272,7 +272,7 @@ public function testDeleteWithInvalidDataException()
272
272
273
273
/**
274
274
* @expectedException \Magento\Framework\Exception\NoSuchEntityException
275
- * @expectedExceptionMessage Product with SKU linkedProduct is not linked to product with SKU product
275
+ * @expectedExceptionMessage Product with SKU ' linkedProduct' is not linked to product with SKU ' product'
276
276
*/
277
277
public function testDeleteWithNoSuchEntityException ()
278
278
{
You can’t perform that action at this time.
0 commit comments