Some Fixes Done
This commit is contained in:
parent
830f586650
commit
078d7e39dc
|
|
@ -811,6 +811,8 @@ class ProductRepository extends Repository
|
|||
}
|
||||
|
||||
/**
|
||||
* Check out of stock items.
|
||||
*
|
||||
* @param Webkul\Product\Models\ProductFlat
|
||||
*
|
||||
* @return Model
|
||||
|
|
@ -820,20 +822,23 @@ class ProductRepository extends Repository
|
|||
->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
|
||||
->where('ps.type', 'configurable')
|
||||
->where(function ($qb) {
|
||||
$qb
|
||||
->selectRaw('SUM(' . DB::getTablePrefix() . 'product_inventories.qty)')
|
||||
->from('product_flat')
|
||||
->leftJoin('product_inventories', 'product_inventories.product_id', '=', 'product_flat.product_id')
|
||||
->whereRaw(DB::getTablePrefix() . 'product_flat.parent_id = ps.id');
|
||||
}, '>', 0);
|
||||
})
|
||||
->orWhere(function ($qb) {
|
||||
$qb
|
||||
->WhereIn('ps.type', ['grouped', 'downloadable', 'bundle', 'booking'])
|
||||
->orwhereIn('ps.type', ['simple', 'virtual'])->where('pv.qty' , '>' , 0);
|
||||
return $qb
|
||||
/* for grouped, downloadable, bundle and booking product */
|
||||
->orWhereIn('ps.type', ['grouped', 'downloadable', 'bundle', 'booking'])
|
||||
/* for simple and virtual product */
|
||||
->orWhere(function ($qb) {
|
||||
return $qb->whereIn('ps.type', ['simple', 'virtual'])->where('pv.qty', '>', 0);
|
||||
})
|
||||
/* for configurable product */
|
||||
->orWhere(function ($qb) {
|
||||
return $qb->where('ps.type', 'configurable')->where(function ($qb) {
|
||||
return $qb
|
||||
->selectRaw('SUM(' . DB::getTablePrefix() . 'product_inventories.qty)')
|
||||
->from('product_flat')
|
||||
->leftJoin('product_inventories', 'product_inventories.product_id', '=', 'product_flat.product_id')
|
||||
->whereRaw(DB::getTablePrefix() . 'product_flat.parent_id = ps.id');
|
||||
}, '>', 0);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue