From 70a37475b818b94c1ebb8c2d130a0b76dc9c9fd2 Mon Sep 17 00:00:00 2001 From: Amanmyrat Date: Wed, 15 Nov 2023 23:36:18 +0500 Subject: [PATCH] Fix related products --- .../Sarga/Shop/src/Repositories/ProductRepository.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/Sarga/Shop/src/Repositories/ProductRepository.php b/packages/Sarga/Shop/src/Repositories/ProductRepository.php index 328e02a..fea3015 100644 --- a/packages/Sarga/Shop/src/Repositories/ProductRepository.php +++ b/packages/Sarga/Shop/src/Repositories/ProductRepository.php @@ -54,20 +54,18 @@ class ProductRepository extends WProductRepository parent::__construct($attributeRepository, $app); } + /** * @param string $categoryId * * @return \Illuminate\Support\Collection */ - - public function getProductsRelatedToCategoryNurgul($product = null, $limit) + public function getProductsRelatedToCategoryNurgul($categoryId = null, $limit) { $qb = $this->model->leftJoin('product_categories', 'products.id', '=', 'product_categories.product_id'); - $product = $this->find($product); - - if (count($product->categories)) { - $qb->where('product_categories.category_id', $product->categories->first()->id); + if ($categoryId) { + $qb->where('product_categories.category_id', $categoryId); } return $qb->paginate($limit);