fixes as per comment
This commit is contained in:
parent
f37d157461
commit
db30a2e442
|
|
@ -61,7 +61,20 @@ class WishlistRepository extends Repository
|
|||
*/
|
||||
public function getCustomerWhishlist()
|
||||
{
|
||||
return $this->model->where([
|
||||
$query = $this->model;
|
||||
|
||||
if (! core()->getConfigData('catalog.products.homepage.out_of_stock_items')) {
|
||||
$query =$this->model
|
||||
->leftJoin('products as ps', 'wishlist.product_id', '=', 'ps.id')
|
||||
->leftJoin('product_inventories as pv', 'ps.id', '=', 'pv.product_id')
|
||||
->where(function ($qb) {
|
||||
$qb
|
||||
->WhereIn('ps.type', ['configurable', 'grouped', 'downloadable', 'bundle', 'booking'])
|
||||
->orwhereIn('ps.type', ['simple', 'virtual'])->where('pv.qty' , '>' , 0);
|
||||
});
|
||||
}
|
||||
|
||||
return $query->where([
|
||||
'channel_id' => core()->getCurrentChannel()->id,
|
||||
'customer_id' => auth()->guard('customer')->user()->id,
|
||||
])->paginate(5);
|
||||
|
|
|
|||
|
|
@ -812,12 +812,12 @@ class ProductRepository extends Repository
|
|||
* @return Model
|
||||
*/
|
||||
public function checkOutOfStockItem($query) {
|
||||
return $query->leftJoin('products', 'product_flat.product_id', '=', 'products.id')
|
||||
->leftJoin('product_inventories', 'product_flat.product_id', '=', 'product_inventories.product_id')
|
||||
return $query->leftJoin('products as ps', 'product_flat.product_id', '=', 'ps.id')
|
||||
->leftJoin('product_inventories as pv', 'product_flat.product_id', '=', 'pv.product_id')
|
||||
->where(function ($qb) {
|
||||
$qb
|
||||
->WhereIn('products.type', ['configurable', 'grouped', 'downloadable', 'bundle', 'booking'])
|
||||
->orwhereIn('products.type', ['simple', 'virtual'])->where('product_inventories.qty' , '>' , 0);
|
||||
->WhereIn('ps.type', ['configurable', 'grouped', 'downloadable', 'bundle', 'booking'])
|
||||
->orwhereIn('ps.type', ['simple', 'virtual'])->where('pv.qty' , '>' , 0);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -380,6 +380,10 @@ class Helper extends Review
|
|||
// @TODO:- query only once insted of 2
|
||||
$productFlat = $this->productFlatRepository->findOneWhere(['id' => $productId]);
|
||||
|
||||
if (! core()->getConfigData('catalog.products.homepage.out_of_stock_items') && ! $productFlat->isSaleable()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($productFlat) {
|
||||
$product = $this->productRepository->findOneWhere(['id' => $productFlat->product_id]);
|
||||
|
||||
|
|
|
|||
|
|
@ -116,6 +116,10 @@ class ProductRepository extends Repository
|
|||
|
||||
$locale = request()->get('locale') ?: app()->getLocale();
|
||||
|
||||
if (! core()->getConfigData('catalog.products.homepage.out_of_stock_items')) {
|
||||
$query = app('Webkul\Product\Repositories\ProductRepository')->checkOutOfStockItem($query);
|
||||
}
|
||||
|
||||
$query = $query->distinct()
|
||||
->addSelect('product_flat.*')
|
||||
->leftJoin('products', 'product_flat.product_id', '=', 'products.id')
|
||||
|
|
|
|||
Loading…
Reference in New Issue