Skip to content

Commit 113bd92

Browse files
author
okarpenko
committed
MAGETWO-34757: Impossible to add configured product from wishlist to shopping cart
1 parent 6e9f410 commit 113bd92

File tree

2 files changed

+56
-13
lines changed

2 files changed

+56
-13
lines changed

app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,12 @@ public function save($product)
326326
return $this;
327327
}
328328

329+
/**
330+
* @param \Magento\Framework\Object $buyRequest
331+
* @param $product
332+
* @param $isStrictProcessMode
333+
* @return array|string
334+
*/
329335
protected function getProductInfo(\Magento\Framework\Object $buyRequest, $product, $isStrictProcessMode)
330336
{
331337
$productsInfo = $buyRequest->getSuperGroup() ?: [];
@@ -355,6 +361,7 @@ protected function getProductInfo(\Magento\Framework\Object $buyRequest, $produc
355361
* @param string $processMode
356362
* @return \Magento\Framework\Phrase|array|string
357363
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
364+
* @SuppressWarnings(PHPMD.NPathComplexity)
358365
*/
359366
protected function _prepareProduct(\Magento\Framework\Object $buyRequest, $product, $processMode)
360367
{
@@ -375,7 +382,7 @@ protected function _prepareProduct(\Magento\Framework\Object $buyRequest, $produ
375382
continue;
376383
}
377384

378-
$_result = $subProduct->getTypeInstance()->_prepareProduct($buyRequest, $subProduct,$processMode);
385+
$_result = $subProduct->getTypeInstance()->_prepareProduct($buyRequest, $subProduct, $processMode);
379386

380387
if (is_string($_result)) {
381388
return $_result;

app/code/Magento/GroupedProduct/Test/Unit/Model/Product/Type/GroupedTest.php

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,14 @@ public function testPrepareForCartAdvancedNoProductsStrictTrue()
391391

392392
$cached = true;
393393
$associatedProducts = [];
394-
$this->product->expects($this->atLeastOnce())->method('hasData')->will($this->returnValue($cached));
395-
$this->product->expects($this->atLeastOnce())->method('getData')->will($this->returnValue($associatedProducts));
394+
$this->product
395+
->expects($this->atLeastOnce())
396+
->method('hasData')
397+
->will($this->returnValue($cached));
398+
$this->product
399+
->expects($this->atLeastOnce())
400+
->method('getData')
401+
->will($this->returnValue($associatedProducts));
396402

397403
$this->assertEquals(
398404
$expectedMsg,
@@ -407,8 +413,14 @@ public function testPrepareForCartAdvancedNoProductsStrictFalse()
407413

408414
$cached = true;
409415
$associatedProducts = [];
410-
$this->product->expects($this->atLeastOnce())->method('hasData')->will($this->returnValue($cached));
411-
$this->product->expects($this->atLeastOnce())->method('getData')->will($this->returnValue($associatedProducts));
416+
$this->product
417+
->expects($this->atLeastOnce())
418+
->method('hasData')
419+
->will($this->returnValue($cached));
420+
$this->product
421+
->expects($this->atLeastOnce())
422+
->method('getData')
423+
->will($this->returnValue($associatedProducts));
412424

413425
$this->assertEquals(
414426
[0 => $this->product],
@@ -438,8 +450,14 @@ public function testPrepareForCartAdvancedWithProductsStrictFalseStringResult()
438450
$buyRequest->setSuperGroup([$associatedId => 1]);
439451

440452
$cached = true;
441-
$this->product->expects($this->atLeastOnce())->method('hasData')->will($this->returnValue($cached));
442-
$this->product->expects($this->atLeastOnce())->method('getData')->will($this->returnValue([$associatedProduct]));
453+
$this->product
454+
->expects($this->atLeastOnce())
455+
->method('hasData')
456+
->will($this->returnValue($cached));
457+
$this->product
458+
->expects($this->atLeastOnce())
459+
->method('getData')
460+
->will($this->returnValue([$associatedProduct]));
443461

444462
$this->assertEquals(
445463
$associatedPrepareResult,
@@ -470,8 +488,14 @@ public function testPrepareForCartAdvancedWithProductsStrictFalseEmptyArrayResul
470488
$buyRequest->setSuperGroup([$associatedId => 1]);
471489

472490
$cached = true;
473-
$this->product->expects($this->atLeastOnce())->method('hasData')->will($this->returnValue($cached));
474-
$this->product->expects($this->atLeastOnce())->method('getData')->will($this->returnValue([$associatedProduct]));
491+
$this->product->
492+
expects($this->atLeastOnce())
493+
->method('hasData')
494+
->will($this->returnValue($cached));
495+
$this->product->
496+
expects($this->atLeastOnce())
497+
->method('getData')
498+
->will($this->returnValue([$associatedProduct]));
475499

476500
$this->assertEquals(
477501
$expectedMsg,
@@ -501,8 +525,14 @@ public function testPrepareForCartAdvancedWithProductsStrictFalse()
501525
$buyRequest->setSuperGroup([$associatedId => 1]);
502526

503527
$cached = true;
504-
$this->product->expects($this->atLeastOnce())->method('hasData')->will($this->returnValue($cached));
505-
$this->product->expects($this->atLeastOnce())->method('getData')->will($this->returnValue([$associatedProduct]));
528+
$this->product
529+
->expects($this->atLeastOnce())
530+
->method('hasData')
531+
->will($this->returnValue($cached));
532+
$this->product
533+
->expects($this->atLeastOnce())
534+
->method('getData')
535+
->will($this->returnValue([$associatedProduct]));
506536

507537
$this->assertEquals(
508538
[$this->product],
@@ -532,8 +562,14 @@ public function testPrepareForCartAdvancedWithProductsStrictTrue()
532562
$buyRequest->setSuperGroup([$associatedId => 1]);
533563

534564
$cached = true;
535-
$this->product->expects($this->atLeastOnce())->method('hasData')->will($this->returnValue($cached));
536-
$this->product->expects($this->atLeastOnce())->method('getData')->will($this->returnValue([$associatedProduct]));
565+
$this->product
566+
->expects($this->atLeastOnce())
567+
->method('hasData')
568+
->will($this->returnValue($cached));
569+
$this->product
570+
->expects($this->atLeastOnce())
571+
->method('getData')
572+
->will($this->returnValue([$associatedProduct]));
537573

538574
$this->assertEquals(
539575
$associatedPrepareResult,

0 commit comments

Comments
 (0)