From f0f413ae41e76ca4e8ddf5417ab9308607919054 Mon Sep 17 00:00:00 2001 From: devansh bawari Date: Tue, 29 Jun 2021 12:47:10 +0530 Subject: [PATCH] Image Search Issue Fixed --- .../Product/src/Repositories/ProductRepository.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/Webkul/Product/src/Repositories/ProductRepository.php b/packages/Webkul/Product/src/Repositories/ProductRepository.php index 29f3dd81b..00454f906 100755 --- a/packages/Webkul/Product/src/Repositories/ProductRepository.php +++ b/packages/Webkul/Product/src/Repositories/ProductRepository.php @@ -466,17 +466,19 @@ class ProductRepository extends Repository } else { $results = app(ProductFlatRepository::class)->scopeQuery(function ($query) use ($term, $channel, $locale) { + $query = $query->distinct() + ->addSelect('product_flat.*') + ->join('product_flat as variants', 'product_flat.id', '=', DB::raw('COALESCE(' . DB::getTablePrefix() . 'variants.parent_id, ' . DB::getTablePrefix() . 'variants.id)')) + ->where('product_flat.channel', $channel) + ->where('product_flat.locale', $locale) + ->whereNotNull('product_flat.url_key'); + if (! core()->getConfigData('catalog.products.homepage.out_of_stock_items')) { $query = $this->checkOutOfStockItem($query); } - return $query->distinct() - ->addSelect('product_flat.*') - ->where('product_flat.status', 1) + return $query->where('product_flat.status', 1) ->where('product_flat.visible_individually', 1) - ->where('product_flat.channel', $channel) - ->where('product_flat.locale', $locale) - ->whereNotNull('product_flat.url_key') ->where(function ($subQuery) use ($term) { $queries = explode('_', $term);