Out Of Stock Query Updated For Configurable Product
This commit is contained in:
parent
db28d93b71
commit
ea3c0874c3
|
|
@ -812,11 +812,22 @@ class ProductRepository extends Repository
|
||||||
* @return Model
|
* @return Model
|
||||||
*/
|
*/
|
||||||
public function checkOutOfStockItem($query) {
|
public function checkOutOfStockItem($query) {
|
||||||
return $query->leftJoin('products as ps', 'product_flat.product_id', '=', 'ps.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')
|
->leftJoin('product_inventories as pv', 'product_flat.product_id', '=', 'pv.product_id')
|
||||||
->where(function ($qb) {
|
->where(function ($qb) {
|
||||||
$qb
|
$qb
|
||||||
->WhereIn('ps.type', ['configurable', 'grouped', 'downloadable', 'bundle', 'booking'])
|
->where('ps.type', 'configurable')
|
||||||
|
->whereRaw('
|
||||||
|
(SELECT SUM(product_inventories.qty)
|
||||||
|
FROM product_flat
|
||||||
|
LEFT JOIN product_inventories ON product_inventories.product_id = product_flat.product_id
|
||||||
|
WHERE 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);
|
->orwhereIn('ps.type', ['simple', 'virtual'])->where('pv.qty' , '>' , 0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue