added search for teamstore
This commit is contained in:
@@ -32,7 +32,43 @@ class TeamStoreController extends Controller
|
||||
$UserModel = new UserModel;
|
||||
|
||||
$store_array = $m->selectTeamStore('StoreUrl', $teamStoreURL);
|
||||
$product_array = $m->selectTeamStoreProducts('TeamStoreId', $store_array[0]->Id);
|
||||
// $product_array = $m->selectTeamStoreProducts('TeamStoreId', $store_array[0]->Id);
|
||||
|
||||
$q = $request->input('q');
|
||||
$sort = $request->input('s');
|
||||
|
||||
if (isset($q) && isset($sort)) {
|
||||
|
||||
if ($sort == "latest") {
|
||||
$field = "Id";
|
||||
$sort_value = "DESC";
|
||||
} elseif ($sort == "al-desc") {
|
||||
$field = "ProductName";
|
||||
$sort_value = "DESC";
|
||||
} elseif ($sort == "oldest") {
|
||||
$field = "Id";
|
||||
$sort_value = "ASC";
|
||||
} else {
|
||||
$field = "ProductName";
|
||||
$sort_value = "ASC";
|
||||
}
|
||||
|
||||
if ($q != "") {
|
||||
// keyword and sort
|
||||
$product_array = $m->searchTeamstoreProducts('TeamStoreId', $store_array[0]->Id, $field, $sort_value, $q);
|
||||
} else {
|
||||
// sort only
|
||||
$product_array = $m->filterTeamstoreProducts('TeamStoreId', $store_array[0]->Id, $field, $sort_value);
|
||||
}
|
||||
} else {
|
||||
$field = "ProductName";
|
||||
$sort_value = "ASC";
|
||||
$sort = "al-asc";
|
||||
$product_array = $m->filterTeamstoreProducts('TeamStoreId', $store_array[0]->Id, $field, $sort_value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$user_role = '';
|
||||
|
||||
if (Auth::check()) {
|
||||
@@ -59,10 +95,14 @@ class TeamStoreController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$thumbnails = [];
|
||||
foreach ($product_array as $p => $pr_arr) {
|
||||
|
||||
$thumbnails_array = $m->getProductThumbnails($pr_arr->Id);
|
||||
$displayThumbnails = "product-image-placeholder.png";
|
||||
|
||||
|
||||
if (!empty($thumbnails_array)) {
|
||||
foreach ($thumbnails_array as $t => $thumb) {
|
||||
|
||||
@@ -104,11 +144,13 @@ class TeamStoreController extends Controller
|
||||
'DateCreated' => ""
|
||||
);
|
||||
}
|
||||
|
||||
// var_dump($thumbnails);
|
||||
return view('teamstore-sublayouts.index')
|
||||
->with('store_array', $store_array)
|
||||
->with('product_array', $product_array)
|
||||
->with('announcement', $data)
|
||||
->with('keyword', $q)
|
||||
->with('filter', $sort)
|
||||
->with('thumbnails', $thumbnails);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user