change table of product datagrid to product_flat

This commit is contained in:
rahul shukla 2019-04-16 18:59:29 +05:30
parent 4e56374c70
commit 095c045c58
1 changed files with 19 additions and 9 deletions

View File

@ -21,15 +21,19 @@ class ProductDataGrid extends DataGrid
public function prepareQueryBuilder()
{
$queryBuilder = DB::table('products_grid')
->leftJoin('products', 'products_grid.product_id', '=', 'products.id')
->leftJoin('attribute_families', 'products.attribute_family_id', '=', 'attribute_families.id')
->select('products_grid.product_id as product_id', 'products_grid.sku as product_sku', 'products_grid.name as product_name', 'products.type as product_type', 'products_grid.status', 'products_grid.price', 'products_grid.quantity', 'attribute_families.name as attribute_family');
$queryBuilder = DB::table('product_flat')
->leftJoin('products', 'product_flat.product_id', '=', 'products.id')
->leftJoin('attribute_families', 'products.attribute_family_id', '=', 'attribute_families.id')
->leftJoin('product_inventories', 'product_flat.product_id', '=', 'product_inventories.product_id')
->select('product_flat.product_id as product_id', 'product_flat.sku as product_sku', 'product_flat.name as product_name', 'products.type as product_type', 'product_flat.status', 'product_flat.price', 'attribute_families.name as attribute_family', DB::raw('SUM(product_inventories.qty) as quantity'))
->where('channel', core()->getCurrentChannelCode())
->where('locale', app()->getLocale())
->groupBy('product_flat.product_id');
$this->addFilter('product_id', 'products_grid.product_id');
$this->addFilter('product_name', 'products_grid.name');
$this->addFilter('product_sku', 'products_grid.sku');
$this->addFilter('status', 'products_grid.status');
$this->addFilter('product_id', 'product_flat.product_id');
$this->addFilter('product_name', 'product_flat.name');
$this->addFilter('product_sku', 'product_flat.sku');
$this->addFilter('status', 'product_flat.status');
$this->addFilter('product_type', 'products.type');
$this->addFilter('attribute_family', 'attribute_families.name');
@ -114,7 +118,13 @@ class ProductDataGrid extends DataGrid
'type' => 'number',
'sortable' => true,
'searchable' => false,
'filterable' => false
'filterable' => false,
'wrapper' => function($value) {
if (is_null($value->quantity))
return 0;
else
return $value->quantity;
}
]);
}