From e571e427eb2ae545b4bfffd3f3acaadb2684aaa0 Mon Sep 17 00:00:00 2001 From: "vishal.kushwaha650" Date: Mon, 12 Oct 2020 19:10:15 +0530 Subject: [PATCH] Issue #4061 Fixed --- .../Product/src/Helpers/ProductImage.php | 42 +++++++++++++++++++ .../account/wishlist/wishlist.blade.php | 1 + .../views/shop/products/list/card.blade.php | 2 +- 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/packages/Webkul/Product/src/Helpers/ProductImage.php b/packages/Webkul/Product/src/Helpers/ProductImage.php index c9a4ab488..dfe335c31 100755 --- a/packages/Webkul/Product/src/Helpers/ProductImage.php +++ b/packages/Webkul/Product/src/Helpers/ProductImage.php @@ -3,9 +3,30 @@ namespace Webkul\Product\Helpers; use Illuminate\Support\Facades\Storage; +use Webkul\Product\Repositories\ProductRepository; class ProductImage extends AbstractProduct { + /** + * ProductRepository instance + * + * @var \Webkul\Product\Repositories\ProductRepository + */ + protected $productRepository; + + /** + * Create a new helper instance. + * + * @param \Webkul\Product\Repositories\ProductRepository $productRepository + * @return void + */ + public function __construct( + ProductRepository $productRepository + ) + { + $this->productRepository = $productRepository; + } + /** * Retrieve collection of gallery images * @@ -73,4 +94,25 @@ class ProductImage extends AbstractProduct return $image; } + + /** + * Get product varient image if available otherwise product base image + * + * @param \Webkul\Customer\Contracts\Wishlist $item + * @return array + */ + public function getProductImage($item) + { + if ($item instanceof \Webkul\Customer\Contracts\Wishlist) { + if (isset($item->additional['selected_configurable_option'])) { + $product = $this->productRepository->find($item->additional['selected_configurable_option']); + } else { + $product = $item->product; + } + } else { + $product = $item->product; + } + + return $this->getProductBaseImage($product); + } } \ No newline at end of file diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/customers/account/wishlist/wishlist.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/customers/account/wishlist/wishlist.blade.php index d784e1a2c..3b946cfb6 100644 --- a/packages/Webkul/Velocity/src/Resources/views/shop/customers/account/wishlist/wishlist.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/shop/customers/account/wishlist/wishlist.blade.php @@ -41,6 +41,7 @@ 'removeWishlist' => true, 'reloadPage' => true, 'itemId' => $item->id, + 'item' => $item, 'product' => $item->product, 'additionalAttributes' => true, 'btnText' => $moveToCartText, diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/products/list/card.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/products/list/card.blade.php index d20a9d92d..e3b9251e3 100644 --- a/packages/Webkul/Velocity/src/Resources/views/shop/products/list/card.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/shop/products/list/card.blade.php @@ -20,7 +20,7 @@ $list = true; } - $productBaseImage = $productImageHelper->getProductBaseImage($product); + $productBaseImage = $productImageHelper->getProductImage($item); $totalReviews = $reviewHelper->getTotalReviews($product); $avgRatings = ceil($reviewHelper->getAverageRating($product));