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