Skip to content

Commit 4870115

Browse files
MAGETWO-86101: Add product ID and SKU to wishlist customer data #12896
2 parents 9037878 + 58990ce commit 4870115

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

app/code/Magento/Wishlist/CustomerData/Wishlist.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ protected function getItemData(\Magento\Wishlist\Model\Item $wishlistItem)
123123
$product = $wishlistItem->getProduct();
124124
return [
125125
'image' => $this->getImageData($product),
126+
'product_sku' => $product->getSku(),
127+
'product_id' => $product->getId(),
126128
'product_url' => $this->wishlistHelper->getProductUrl($wishlistItem),
127129
'product_name' => $product->getName(),
128130
'product_price' => $this->block->getProductPriceHtml(

app/code/Magento/Wishlist/Test/Unit/CustomerData/WishlistTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ public function testGetSectionData()
7777
$imageLabel = 'image_label';
7878
$imageWidth = 'image_width';
7979
$imageHeight = 'image_height';
80+
$productSku = 'product_sku';
81+
$productId = 'product_id';
8082
$productUrl = 'product_url';
8183
$productName = 'product_name';
8284
$productPrice = 'product_price';
@@ -97,6 +99,8 @@ public function testGetSectionData()
9799
'width' => $imageWidth,
98100
'height' => $imageHeight,
99101
],
102+
'product_sku' => $productSku,
103+
'product_id' => $productId,
100104
'product_url' => $productUrl,
101105
'product_name' => $productName,
102106
'product_price' => $productPrice,
@@ -186,6 +190,12 @@ public function testGetSectionData()
186190
->with($itemMock, [])
187191
->willReturn($productUrl);
188192

193+
$productMock->expects($this->once())
194+
->method('getSku')
195+
->willReturn($productSku);
196+
$productMock->expects($this->once())
197+
->method('getId')
198+
->willReturn($productId);
189199
$productMock->expects($this->once())
190200
->method('getName')
191201
->willReturn($productName);
@@ -246,6 +256,8 @@ public function testGetSectionDataWithTwoItems()
246256
$imageLabel = 'image_label';
247257
$imageWidth = 'image_width';
248258
$imageHeight = 'image_height';
259+
$productSku = 'product_sku';
260+
$productId = 'product_id';
249261
$productUrl = 'product_url';
250262
$productName = 'product_name';
251263
$productPrice = 'product_price';
@@ -272,6 +284,8 @@ public function testGetSectionDataWithTwoItems()
272284
'width' => $imageWidth,
273285
'height' => $imageHeight,
274286
],
287+
'product_sku' => $productSku,
288+
'product_id' => $productId,
275289
'product_url' => $productUrl,
276290
'product_name' => $productName,
277291
'product_price' => $productPrice,
@@ -288,6 +302,8 @@ public function testGetSectionDataWithTwoItems()
288302
'width' => $imageWidth,
289303
'height' => $imageHeight,
290304
],
305+
'product_sku' => $productSku,
306+
'product_id' => $productId,
291307
'product_url' => $productUrl,
292308
'product_name' => $productName,
293309
'product_price' => $productPrice,
@@ -375,6 +391,14 @@ public function testGetSectionDataWithTwoItems()
375391
->method('getName')
376392
->willReturn($productName);
377393

394+
$productMock->expects($this->exactly(2))
395+
->method('getId')
396+
->willReturn($productId);
397+
398+
$productMock->expects($this->exactly(2))
399+
->method('getSku')
400+
->willReturn($productSku);
401+
378402
$this->sidebarMock->expects($this->exactly(2))
379403
->method('getProductPriceHtml')
380404
->with(

0 commit comments

Comments
 (0)