From b315babc8c31f5caf573ac47dcdf4fcb1ee8b379 Mon Sep 17 00:00:00 2001 From: jitendra Date: Tue, 29 Jan 2019 18:40:14 +0530 Subject: [PATCH] Refactor product repository --- .../src/Repositories/ProductRepository.php | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/packages/Webkul/Product/src/Repositories/ProductRepository.php b/packages/Webkul/Product/src/Repositories/ProductRepository.php index edc9c46d3..1bcd481a1 100755 --- a/packages/Webkul/Product/src/Repositories/ProductRepository.php +++ b/packages/Webkul/Product/src/Repositories/ProductRepository.php @@ -401,11 +401,11 @@ class ProductRepository extends Repository * @param integer $categoryId * @return Collection */ - public function findAllByCategoryQueryBuilder($categoryId = null) + public function findAllByCategory($categoryId = null) { $params = request()->input(); - return app('Webkul\Product\Repositories\ProductFlatRepository')->scopeQuery(function($query) use($params, $categoryId) { + $results = app('Webkul\Product\Repositories\ProductFlatRepository')->scopeQuery(function($query) use($params, $categoryId) { $channel = request()->get('channel') ?: (core()->getCurrentChannelCode() ?: core()->getDefaultChannelCode()); $locale = request()->get('locale') ?: app()->getLocale(); @@ -466,18 +466,7 @@ class ProductRepository extends Repository }); return $qb; - }); - } - - /** - * @param integer $categoryId - * @return Collection - */ - public function findAllByCategory($categoryId = null) - { - $params = request()->input(); - - $results = $this->findAllByCategoryQueryBuilder($categoryId)->paginate(isset($params['limit']) ? $params['limit'] : 9); + })->paginate(isset($params['limit']) ? $params['limit'] : 9); return $results; }