fix: show prods from the same ctgr but not repeating the current prod in single-prod page

This commit is contained in:
saparatayev 2021-08-28 14:17:40 +05:00
parent 661ec831db
commit 7db7acff07
1 changed files with 3 additions and 1 deletions

View File

@ -109,7 +109,9 @@ class Offers extends ComponentBase
if($productSlug != '' && $offerId != '') { // fetch offers with similar products
$product = Product::transWhere('slug', $productSlug, Session::get('rainlab.translate.locale'))->first();
if($product) {
$query = Product::where('id','!=',$offerId)->where('status','approved')->where('ends_at','>=',DB::raw('curdate()'))->orderBy('created_at', $sortOrder);
$category = $product->categories->first();
$query = $category->products()->where('id','!=',$offerId)->where('status','approved')->where('ends_at','>=',DB::raw('curdate()'))->orderBy('created_at', $sortOrder);
} else {
$query = null;
}