From 7db7acff076699188bda9852eeebbc92fc8f44ed Mon Sep 17 00:00:00 2001 From: saparatayev Date: Sat, 28 Aug 2021 14:17:40 +0500 Subject: [PATCH] fix: show prods from the same ctgr but not repeating the current prod in single-prod page --- plugins/tps/birzha/components/Offers.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/tps/birzha/components/Offers.php b/plugins/tps/birzha/components/Offers.php index b720a5bd2..e83c11722 100644 --- a/plugins/tps/birzha/components/Offers.php +++ b/plugins/tps/birzha/components/Offers.php @@ -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; }