Skip to content

Commit 635e4dc

Browse files
MAGETWO-86204: Fix wishlist item getBuyRequest with no options #12930
- Merge Pull Request #12930 from jameshalsall/magento2:fix-wishlist-get-buy-request-with-no-options - Merged commits: 1. 79256fd
2 parents e738316 + 79256fd commit 635e4dc

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

app/code/Magento/Wishlist/Model/Item.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ public function getProductUrl()
472472
public function getBuyRequest()
473473
{
474474
$option = $this->getOptionByCode('info_buyRequest');
475-
$initialData = $option ? unserialize($option->getValue()) : null;
475+
$initialData = $option ? unserialize($option->getValue()) : [];
476476

477477
if ($initialData instanceof \Magento\Framework\DataObject) {
478478
$initialData = $initialData->getData();

app/code/Magento/Wishlist/Test/Unit/Model/ItemTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,4 +323,15 @@ public function testGetProduct()
323323
->willReturn($productMock);
324324
$this->assertEquals($productMock, $this->model->getProduct());
325325
}
326+
327+
public function testGetBuyRequestWithNoOption()
328+
{
329+
$buyRequest = $this->model->getBuyRequest();
330+
331+
$this->assertInstanceOf(\Magento\Framework\DataObject::class, $buyRequest);
332+
$this->assertEquals([
333+
'qty' => 0,
334+
'original_qty' => null
335+
], $buyRequest->getData());
336+
}
326337
}

0 commit comments

Comments
 (0)