search suggestions start
This commit is contained in:
parent
6827a1f8c9
commit
a94ffe73c6
|
|
@ -11,6 +11,7 @@ use Sarga\Shop\Repositories\ProductRepository;
|
|||
use Webkul\API\Http\Controllers\Shop\ProductController;
|
||||
use Sarga\API\Http\Resources\Catalog\Product as ProductResource;
|
||||
use Sarga\Shop\Repositories\AttributeOptionRepository;
|
||||
use Webkul\Product\Repositories\ProductFlatRepository;
|
||||
|
||||
|
||||
class Products extends ProductController
|
||||
|
|
@ -131,6 +132,18 @@ class Products extends ProductController
|
|||
// ->get();
|
||||
|
||||
$products = $this->productRepository->searchProductByAttribute($key);
|
||||
$queries = explode(' ', $key);
|
||||
$channel = core()->getRequestedChannelCode();
|
||||
|
||||
$locale = core()->getRequestedLocaleCode();
|
||||
$results = app(ProductFlatRepository::class)->getModel()::search(implode(' OR ', $queries))
|
||||
->select('product_id','sku','name','product_number','url_key',)
|
||||
->where('status', 1)
|
||||
->where('visible_individually', 1)
|
||||
->where('channel', $channel)
|
||||
->where('locale', $locale)
|
||||
->orderBy('product_id', 'desc')
|
||||
->limit(10);
|
||||
|
||||
return $products;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Laravel\Scout\Searchable;
|
||||
use Sarga\Brand\Contracts\Brand as BrandContract;
|
||||
use Webkul\Category\Models\CategoryProxy;
|
||||
use Webkul\Marketplace\Models\SellerProxy;
|
||||
|
|
@ -11,13 +12,30 @@ use Webkul\Product\Models\ProductProxy;
|
|||
|
||||
class Brand extends Model implements BrandContract
|
||||
{
|
||||
use Searchable;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'brands';
|
||||
|
||||
protected $fillable = [
|
||||
'position',
|
||||
'status',
|
||||
'code',
|
||||
'name'
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the index name for the model.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function searchableAs()
|
||||
{
|
||||
return 'brands_index';
|
||||
}
|
||||
/**
|
||||
* Get image url for the category image.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue