From 93a5ec7d56b56a970d02246b7de339b050f3bffd Mon Sep 17 00:00:00 2001 From: nikolayandreev Date: Tue, 23 Feb 2021 13:23:22 +0200 Subject: [PATCH] Revert the parameter rename, but keep new functionality --- .../API/Http/Controllers/Shop/ProductController.php | 2 +- .../Product/src/Repositories/ProductRepository.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/Webkul/API/Http/Controllers/Shop/ProductController.php b/packages/Webkul/API/Http/Controllers/Shop/ProductController.php index 992dc66e6..051982e51 100755 --- a/packages/Webkul/API/Http/Controllers/Shop/ProductController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/ProductController.php @@ -34,7 +34,7 @@ class ProductController extends Controller */ public function index() { - return ProductResource::collection($this->productRepository->getAll(request()->input('categories'))); + return ProductResource::collection($this->productRepository->getAll(request()->input('category_id'))); } /** diff --git a/packages/Webkul/Product/src/Repositories/ProductRepository.php b/packages/Webkul/Product/src/Repositories/ProductRepository.php index 3a686f7e7..4da361477 100755 --- a/packages/Webkul/Product/src/Repositories/ProductRepository.php +++ b/packages/Webkul/Product/src/Repositories/ProductRepository.php @@ -129,11 +129,11 @@ class ProductRepository extends Repository } /** - * @param string $categories + * @param string $categoryId * * @return \Illuminate\Support\Collection */ - public function getAll($categories = null) + public function getAll($categoryId = null) { $params = request()->input(); @@ -147,7 +147,7 @@ class ProductRepository extends Repository $page = Paginator::resolveCurrentPage('page'); - $repository = app(ProductFlatRepository::class)->scopeQuery(function ($query) use ($params, $categories) { + $repository = app(ProductFlatRepository::class)->scopeQuery(function ($query) use ($params, $categoryId) { $channel = request()->get('channel') ?: (core()->getCurrentChannelCode() ?: core()->getDefaultChannelCode()); $locale = request()->get('locale') ?: app()->getLocale(); @@ -161,8 +161,8 @@ class ProductRepository extends Repository ->where('product_flat.locale', $locale) ->whereNotNull('product_flat.url_key'); - if ($categories) { - $qb->whereIn('product_categories.category_id', explode(',', $categories)); + if ($categoryId) { + $qb->whereIn('product_categories.category_id', explode(',', $categoryId)); } if (! core()->getConfigData('catalog.products.homepage.out_of_stock_items')) {