diff --git a/src/Http/Controllers/CP/ProductAttributeController.php b/src/Http/Controllers/CP/ProductAttributeController.php index a7e1e62..490cd10 100644 --- a/src/Http/Controllers/CP/ProductAttributeController.php +++ b/src/Http/Controllers/CP/ProductAttributeController.php @@ -2,6 +2,7 @@ namespace Rapidez\StatamicQueryBuilder\Http\Controllers\CP; +use Rapidez\StatamicQueryBuilder\Models\ProductAttribute as QueryBuilderProductAttribute; use Statamic\Http\Controllers\CP\CpController; class ProductAttributeController extends CpController @@ -13,8 +14,19 @@ public function index() return []; } - return $model::with('attributeOptions') - ->filterable() - ->get(); + $query = $model::with('attributeOptions'); + + // Pick the correct filter strategy for the configured model. + if (is_a($model, QueryBuilderProductAttribute::class, true)) { + $query->filterable(); + } else { + $query->whereIn('eav_attribute.attribute_id', function ($subQuery) { + $subQuery->select('attribute_id') + ->from('catalog_eav_attribute') + ->where('is_filterable', '>', 0); + }); + } + + return $query->get(); } }