diff --git a/packages/Sarga/Shop/src/Repositories/ProductRepository.php b/packages/Sarga/Shop/src/Repositories/ProductRepository.php index d94661f..f73990a 100644 --- a/packages/Sarga/Shop/src/Repositories/ProductRepository.php +++ b/packages/Sarga/Shop/src/Repositories/ProductRepository.php @@ -60,12 +60,14 @@ class ProductRepository extends WProductRepository * @return \Illuminate\Support\Collection */ - public function getProductsRelatedToCategoryNurgul($categoryId = null, $limit) + public function getProductsRelatedToCategoryNurgul($product = null, $limit) { $qb = $this->model->leftJoin('product_categories', 'products.id', '=', 'product_categories.product_id'); - if ($categoryId) { - $qb->where('product_categories.category_id', $categoryId); + $product = $this->find($product); + + if (count($product->categories)) { + $qb->where('product_categories.category_id', $product->categories->first->id); } return $qb->paginate($limit);