Fix related products
This commit is contained in:
parent
a83cf91a75
commit
70a37475b8
|
|
@ -54,20 +54,18 @@ class ProductRepository extends WProductRepository
|
|||
|
||||
parent::__construct($attributeRepository, $app);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $categoryId
|
||||
*
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
|
||||
public function getProductsRelatedToCategoryNurgul($product = null, $limit)
|
||||
public function getProductsRelatedToCategoryNurgul($categoryId = null, $limit)
|
||||
{
|
||||
$qb = $this->model->leftJoin('product_categories', 'products.id', '=', 'product_categories.product_id');
|
||||
|
||||
$product = $this->find($product);
|
||||
|
||||
if (count($product->categories)) {
|
||||
$qb->where('product_categories.category_id', $product->categories->first()->id);
|
||||
if ($categoryId) {
|
||||
$qb->where('product_categories.category_id', $categoryId);
|
||||
}
|
||||
|
||||
return $qb->paginate($limit);
|
||||
|
|
|
|||
Loading…
Reference in New Issue