From 0d27287bb8c3e2fc29414d65dba2a34ead0dd8ed Mon Sep 17 00:00:00 2001 From: James Halsall Date: Wed, 27 Dec 2017 16:43:10 +0000 Subject: [PATCH] Add product ID and SKU to wishlist customer data --- .../Wishlist/CustomerData/Wishlist.php | 2 ++ .../Test/Unit/CustomerData/WishlistTest.php | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/app/code/Magento/Wishlist/CustomerData/Wishlist.php b/app/code/Magento/Wishlist/CustomerData/Wishlist.php index 6933efc2aa540..14d651f43afdc 100644 --- a/app/code/Magento/Wishlist/CustomerData/Wishlist.php +++ b/app/code/Magento/Wishlist/CustomerData/Wishlist.php @@ -123,6 +123,8 @@ protected function getItemData(\Magento\Wishlist\Model\Item $wishlistItem) $product = $wishlistItem->getProduct(); return [ 'image' => $this->getImageData($product), + 'product_sku' => $product->getSku(), + 'product_id' => $product->getId(), 'product_url' => $this->wishlistHelper->getProductUrl($wishlistItem), 'product_name' => $product->getName(), 'product_price' => $this->block->getProductPriceHtml( diff --git a/app/code/Magento/Wishlist/Test/Unit/CustomerData/WishlistTest.php b/app/code/Magento/Wishlist/Test/Unit/CustomerData/WishlistTest.php index 9ecd58b44f0e5..be31cb8f8d0c5 100644 --- a/app/code/Magento/Wishlist/Test/Unit/CustomerData/WishlistTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/CustomerData/WishlistTest.php @@ -77,6 +77,8 @@ public function testGetSectionData() $imageLabel = 'image_label'; $imageWidth = 'image_width'; $imageHeight = 'image_height'; + $productSku = 'product_sku'; + $productId = 'product_id'; $productUrl = 'product_url'; $productName = 'product_name'; $productPrice = 'product_price'; @@ -97,6 +99,8 @@ public function testGetSectionData() 'width' => $imageWidth, 'height' => $imageHeight, ], + 'product_sku' => $productSku, + 'product_id' => $productId, 'product_url' => $productUrl, 'product_name' => $productName, 'product_price' => $productPrice, @@ -186,6 +190,12 @@ public function testGetSectionData() ->with($itemMock, []) ->willReturn($productUrl); + $productMock->expects($this->once()) + ->method('getSku') + ->willReturn($productSku); + $productMock->expects($this->once()) + ->method('getId') + ->willReturn($productId); $productMock->expects($this->once()) ->method('getName') ->willReturn($productName); @@ -246,6 +256,8 @@ public function testGetSectionDataWithTwoItems() $imageLabel = 'image_label'; $imageWidth = 'image_width'; $imageHeight = 'image_height'; + $productSku = 'product_sku'; + $productId = 'product_id'; $productUrl = 'product_url'; $productName = 'product_name'; $productPrice = 'product_price'; @@ -272,6 +284,8 @@ public function testGetSectionDataWithTwoItems() 'width' => $imageWidth, 'height' => $imageHeight, ], + 'product_sku' => $productSku, + 'product_id' => $productId, 'product_url' => $productUrl, 'product_name' => $productName, 'product_price' => $productPrice, @@ -288,6 +302,8 @@ public function testGetSectionDataWithTwoItems() 'width' => $imageWidth, 'height' => $imageHeight, ], + 'product_sku' => $productSku, + 'product_id' => $productId, 'product_url' => $productUrl, 'product_name' => $productName, 'product_price' => $productPrice, @@ -375,6 +391,14 @@ public function testGetSectionDataWithTwoItems() ->method('getName') ->willReturn($productName); + $productMock->expects($this->exactly(2)) + ->method('getId') + ->willReturn($productId); + + $productMock->expects($this->exactly(2)) + ->method('getSku') + ->willReturn($productSku); + $this->sidebarMock->expects($this->exactly(2)) ->method('getProductPriceHtml') ->with(