From 2cfabfc7357d7c40176d63c26e47302263c4e28a Mon Sep 17 00:00:00 2001 From: Amanmyrat Date: Thu, 21 Sep 2023 12:46:35 +0500 Subject: [PATCH] Add marketplace seller to search repository --- packages/Sarga/API/Http/Controllers/Products.php | 2 +- .../Sarga/Shop/src/Repositories/ProductRepository.php | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/Sarga/API/Http/Controllers/Products.php b/packages/Sarga/API/Http/Controllers/Products.php index 8b61527..4158d10 100644 --- a/packages/Sarga/API/Http/Controllers/Products.php +++ b/packages/Sarga/API/Http/Controllers/Products.php @@ -178,7 +178,7 @@ class Products extends ProductController public function searchProducts() { // return $this->productRepository->searchProductByAttribute(request('key')); - return ProductResource::collection($this->productRepository->searchProductByAttribute(request('key'))); + return ProductResource::collection($this->productRepository->searchProductByAttributeDagdan(request('key'))); } public function discountedProducts() diff --git a/packages/Sarga/Shop/src/Repositories/ProductRepository.php b/packages/Sarga/Shop/src/Repositories/ProductRepository.php index 9c5ea4e..158451d 100644 --- a/packages/Sarga/Shop/src/Repositories/ProductRepository.php +++ b/packages/Sarga/Shop/src/Repositories/ProductRepository.php @@ -73,7 +73,7 @@ class ProductRepository extends WProductRepository return $qb->paginate($limit); } - public function searchProductByAttributeNurgul($term, $perPage) + public function searchProductByAttributeDagdan($term, $perPage) { $channel = core()->getRequestedChannelCode(); @@ -117,7 +117,11 @@ class ProductRepository extends WProductRepository ->addSelect('product_flat.*') ->where('product_flat.channel', $channel) ->where('product_flat.locale', $locale) - ->whereNotNull('product_flat.url_key'); + ->whereNotNull('product_flat.url_key') + + ->leftJoin('marketplace_products', 'product_flat.product_id', '=', 'marketplace_products.product_id') + ->leftJoin('marketplace_sellers', 'marketplace_sellers.id', '=', 'marketplace_products.marketplace_seller_id') + ->addSelect('marketplace_sellers.shop_title'); if (! core()->getConfigData('catalog.products.homepage.out_of_stock_items')) { $query = $this->checkOutOfStockItem($query);