Merge pull request #4695 from devansh-webkul/issue-4686
Fixed configurable item which is still visible on search page when out of stock is disabled #4686
This commit is contained in:
commit
e58d64e38c
|
|
@ -11,12 +11,12 @@ use Webkul\Core\Eloquent\Repository;
|
|||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Attribute\Models\Attribute;
|
||||
use Webkul\Product\Models\ProductFlat;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Container\Container as App;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Webkul\Product\Models\ProductAttributeValueProxy;
|
||||
use Webkul\Attribute\Repositories\AttributeRepository;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class ProductRepository extends Repository
|
||||
{
|
||||
|
|
@ -816,11 +816,23 @@ class ProductRepository extends Repository
|
|||
* @return Model
|
||||
*/
|
||||
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')
|
||||
->where(function ($qb) {
|
||||
$qb
|
||||
->WhereIn('ps.type', ['configurable', 'grouped', 'downloadable', 'bundle', 'booking'])
|
||||
->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);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue