diff --git a/packages/Webkul/Shop/src/Http/Controllers/CategoryController.php b/packages/Webkul/Shop/src/Http/Controllers/CategoryController.php
index 168c5657a..cbb6c689e 100755
--- a/packages/Webkul/Shop/src/Http/Controllers/CategoryController.php
+++ b/packages/Webkul/Shop/src/Http/Controllers/CategoryController.php
@@ -2,7 +2,9 @@
namespace Webkul\Shop\Http\Controllers;
+use Webkul\Attribute\Repositories\AttributeRepository;
use Webkul\Category\Repositories\CategoryRepository;
+use Webkul\Product\Repositories\ProductFlatRepository;
class CategoryController extends Controller
{
@@ -10,10 +12,49 @@ class CategoryController extends Controller
* Create a new controller instance.
*
* @param \Webkul\Category\Repositories\CategoryRepository $categoryRepository
+ * @param \Webkul\Product\Repositories\ProductFlatRepository $productFlatRepository
* @return void
*/
- public function __construct(protected CategoryRepository $categoryRepository)
+ public function __construct(
+ protected CategoryRepository $categoryRepository,
+ protected ProductFlatRepository $productFlatRepository
+
+ )
{
parent::__construct();
}
+
+ /**
+ * Get filter attributes for product.
+ *
+ * @return \Illuminate\Http\Response
+ */
+ public function getFilterAttributes($categoryId = null, AttributeRepository $attributeRepository)
+ {
+ $category = $this->categoryRepository->findOrFail($categoryId);
+
+ if (empty($filterAttributes = $category->filterableAttributes)) {
+ $filterAttributes = $attributeRepository->getFilterAttributes();
+ }
+
+ return response()->json([
+ 'filter_attributes' => $filterAttributes,
+ ]);
+ }
+
+ /**
+ * Get category product maximum price.
+ *
+ * @return \Illuminate\Http\Response
+ */
+ public function getCategoryProductMaximumPrice($categoryId = null)
+ {
+ $category = $this->categoryRepository->findOrFail($categoryId);
+
+ $maxPrice = $this->productFlatRepository->handleCategoryProductMaximumPrice($category);
+
+ return response()->json([
+ 'max_price' => $maxPrice,
+ ]);
+ }
}
diff --git a/packages/Webkul/Shop/src/Http/Controllers/ProductController.php b/packages/Webkul/Shop/src/Http/Controllers/ProductController.php
index 41b419477..2ad14209c 100755
--- a/packages/Webkul/Shop/src/Http/Controllers/ProductController.php
+++ b/packages/Webkul/Shop/src/Http/Controllers/ProductController.php
@@ -4,33 +4,24 @@ namespace Webkul\Shop\Http\Controllers;
use Illuminate\Support\Facades\Storage;
use Webkul\Attribute\Repositories\AttributeRepository;
-use Webkul\Category\Repositories\CategoryRepository;
use Webkul\Product\Repositories\ProductAttributeValueRepository;
use Webkul\Product\Repositories\ProductDownloadableLinkRepository;
use Webkul\Product\Repositories\ProductDownloadableSampleRepository;
-use Webkul\Product\Repositories\ProductFlatRepository;
-use Webkul\Product\Repositories\ProductRepository;
class ProductController extends Controller
{
/**
* Create a new controller instance.
*
- * @param \Webkul\Product\Repositories\ProductRepository $productRepository
- * @param \Webkul\Product\Repositories\ProductFlatRepository $productFlatRepository
* @param \Webkul\Product\Repositories\ProductAttributeValueRepository $productAttributeValueRepository
* @param \Webkul\Product\Repositories\ProductDownloadableSampleRepository $productDownloadableSampleRepository
* @param \Webkul\Product\Repositories\ProductDownloadableLinkRepository $productDownloadableLinkRepository
- * @param \Webkul\Category\Repositories\CategoryRepository $categoryRepository
* @return void
*/
public function __construct(
- protected ProductRepository $productRepository,
- protected ProductFlatRepository $productFlatRepository,
protected ProductAttributeValueRepository $productAttributeValueRepository,
protected ProductDownloadableSampleRepository $productDownloadableSampleRepository,
- protected ProductDownloadableLinkRepository $productDownloadableLinkRepository,
- protected CategoryRepository $categoryRepository
+ protected ProductDownloadableLinkRepository $productDownloadableLinkRepository
)
{
parent::__construct();
@@ -100,40 +91,4 @@ class ProductController extends Controller
abort(404);
}
}
-
- /**
- * Get filter attributes for product.
- *
- * @return \Illuminate\Http\Response
- */
- public function getFilterAttributes($categoryId = null, AttributeRepository $attributeRepository)
- {
- $category = $this->categoryRepository->findOrFail($categoryId);
-
- if (empty($filterAttributes = $category->filterableAttributes)) {
- $filterAttributes = $attributeRepository->getFilterAttributes();
- }
-
- return response()->json([
- 'filter_attributes' => $filterAttributes,
- ]);
- }
-
- /**
- * Get category product maximum price.
- *
- * @return \Illuminate\Http\Response
- */
- public function getCategoryProductMaximumPrice($categoryId = null)
- {
- $maxPrice = 0;
-
- if ($category = $this->categoryRepository->find($categoryId)) {
- $maxPrice = $this->productFlatRepository->handleCategoryProductMaximumPrice($category);
- }
-
- return response()->json([
- 'max_price' => $maxPrice,
- ]);
- }
}
diff --git a/packages/Webkul/Shop/src/Resources/views/products/list/layered-navigation.blade.php b/packages/Webkul/Shop/src/Resources/views/products/list/layered-navigation.blade.php
index 44bb9670b..6cdb0e6e0 100755
--- a/packages/Webkul/Shop/src/Resources/views/products/list/layered-navigation.blade.php
+++ b/packages/Webkul/Shop/src/Resources/views/products/list/layered-navigation.blade.php
@@ -2,8 +2,8 @@
{!! view_render_event('bagisto.shop.products.list.layered-nagigation.before') !!}
+ attribute-src="{{ route('catalog.categories.filterable-attributes', $category->id ?? null) }}"
+ max-price-src="{{ route('catalog.categories.maximum-price', $category->id ?? null) }}">
{!! view_render_event('bagisto.shop.products.list.layered-nagigation.after') !!}
diff --git a/packages/Webkul/Shop/src/Routes/store-front-routes.php b/packages/Webkul/Shop/src/Routes/store-front-routes.php
index 369f24361..8bd0b8690 100644
--- a/packages/Webkul/Shop/src/Routes/store-front-routes.php
+++ b/packages/Webkul/Shop/src/Routes/store-front-routes.php
@@ -4,6 +4,7 @@ use Illuminate\Support\Facades\Route;
use Webkul\CMS\Http\Controllers\Shop\PagePresenterController;
use Webkul\Shop\Http\Controllers\HomeController;
use Webkul\Shop\Http\Controllers\ProductController;
+use Webkul\Shop\Http\Controllers\CategoryController;
use Webkul\Shop\Http\Controllers\ReviewController;
use Webkul\Shop\Http\Controllers\SearchController;
use Webkul\Shop\Http\Controllers\SubscriptionController;
@@ -79,7 +80,7 @@ Route::group(['middleware' => ['web', 'locale', 'theme', 'currency']], function
'view' => 'shop.products.index',
])->name('shop.product.file.download');
- Route::get('products/get-filter-attributes/{categoryId?}', [ProductController::class, 'getFilterAttributes'])->name('admin.catalog.products.get-filter-attributes');
+ Route::get('categories/filterable-attributes/{categoryId?}', [CategoryController::class, 'getFilterAttributes'])->name('catalog.categories.filterable-attributes');
- Route::get('products/get-category-product-maximum-price/{categoryId?}', [ProductController::class, 'getCategoryProductMaximumPrice'])->name('admin.catalog.products.get-category-product-maximum-price');
+ Route::get('categories/maximum-price/{categoryId?}', [CategoryController::class, 'getCategoryProductMaximumPrice'])->name('catalog.categories.maximum-price');
});
diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/products/list/layered-navigation.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/products/list/layered-navigation.blade.php
index 1de0cd3ec..a360196ed 100644
--- a/packages/Webkul/Velocity/src/Resources/views/shop/products/list/layered-navigation.blade.php
+++ b/packages/Webkul/Velocity/src/Resources/views/shop/products/list/layered-navigation.blade.php
@@ -2,8 +2,8 @@
{!! view_render_event('bagisto.shop.products.list.layered-nagigation.before') !!}
+ attribute-src="{{ route('catalog.categories.filterable-attributes', $category->id ?? null) }}"
+ max-price-src="{{ route('catalog.categories.maximum-price', $category->id ?? null) }}">
{!! view_render_event('bagisto.shop.products.list.layered-nagigation.after') !!}