Skip to content

Commit d8a21a6

Browse files
committed
issue #2146 has been fixed.
1 parent 8891af8 commit d8a21a6

File tree

8 files changed

+33
-3
lines changed

8 files changed

+33
-3
lines changed

packages/Webkul/Admin/src/DataGrids/Product/ProductDataGrid.php

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Database\Query\Builder;
66
use Illuminate\Support\Facades\DB;
77
use Webkul\DataGrid\DataGrid;
8+
use Webkul\Tag\Repositories\TagRepository;
89

910
class ProductDataGrid extends DataGrid
1011
{
@@ -17,15 +18,18 @@ public function prepareQueryBuilder(): Builder
1718

1819
$queryBuilder = DB::table('products')
1920
->leftJoin('product_inventories', 'products.id', '=', 'product_inventories.product_id')
21+
->leftJoin('product_tags', 'products.id', '=', 'product_tags.product_id')
22+
->leftJoin('tags', 'tags.id', '=', 'product_tags.tag_id')
2023
->select(
2124
'products.id',
2225
'products.sku',
2326
'products.name',
2427
'products.price',
28+
'tags.name as tag_name',
2529
)
26-
->addSelect(DB::raw('SUM('.$tablePrefix.'product_inventories.in_stock) as total_in_stock'))
27-
->addSelect(DB::raw('SUM('.$tablePrefix.'product_inventories.allocated) as total_allocated'))
28-
->addSelect(DB::raw('SUM('.$tablePrefix.'product_inventories.in_stock - '.$tablePrefix.'product_inventories.allocated) as total_on_hand'))
30+
->addSelect(DB::raw('SUM(product_inventories.in_stock) as total_in_stock'))
31+
->addSelect(DB::raw('SUM(product_inventories.allocated) as total_allocated'))
32+
->addSelect(DB::raw('SUM(product_inventories.in_stock - product_inventories.allocated) as total_on_hand'))
2933
->groupBy('products.id');
3034

3135
if (request()->route('id')) {
@@ -36,6 +40,7 @@ public function prepareQueryBuilder(): Builder
3640
$this->addFilter('total_in_stock', DB::raw('SUM('.$tablePrefix.'product_inventories.in_stock'));
3741
$this->addFilter('total_allocated', DB::raw('SUM('.$tablePrefix.'product_inventories.allocated'));
3842
$this->addFilter('total_on_hand', DB::raw('SUM('.$tablePrefix.'product_inventories.in_stock - '.$tablePrefix.'product_inventories.allocated'));
43+
$this->addFilter('tag_name', 'tags.name');
3944

4045
return $queryBuilder;
4146
}
@@ -93,6 +98,24 @@ public function prepareColumns(): void
9398
'type' => 'string',
9499
'sortable' => true,
95100
]);
101+
102+
$this->addColumn([
103+
'index' => 'tag_name',
104+
'label' => trans('admin::app.products.index.datagrid.tag-name'),
105+
'type' => 'string',
106+
'searchable' => false,
107+
'sortable' => true,
108+
'filterable' => true,
109+
'filterable_type' => 'searchable_dropdown',
110+
'closure' => fn ($row) => $row->tag_name ?? '--',
111+
'filterable_options' => [
112+
'repository' => TagRepository::class,
113+
'column' => [
114+
'label' => 'name',
115+
'value' => 'name',
116+
],
117+
],
118+
]);
96119
}
97120

98121
/**

packages/Webkul/Admin/src/Resources/lang/ar/app.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@
685685
'edit' => 'تعديل',
686686
'id' => 'المعرف',
687687
'in-stock' => 'في المخزون',
688+
'tag-name' => 'اسم الوسم',
688689
'name' => 'الاسم',
689690
'on-hand' => 'متوفر',
690691
'price' => 'السعر',

packages/Webkul/Admin/src/Resources/lang/en/app.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,7 @@
689689
'in-stock' => 'In Stock',
690690
'name' => 'Name',
691691
'on-hand' => 'On Hand',
692+
'tag-name' => 'Tag Name',
692693
'price' => 'Price',
693694
'sku' => 'SKU',
694695
'view' => 'View',

packages/Webkul/Admin/src/Resources/lang/es/app.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,7 @@
689689
'edit' => 'Editar',
690690
'id' => 'ID',
691691
'in-stock' => 'En Stock',
692+
'tag-name' => 'Nombre de etiqueta',
692693
'name' => 'Nombre',
693694
'on-hand' => 'Disponible',
694695
'price' => 'Precio',

packages/Webkul/Admin/src/Resources/lang/fa/app.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,7 @@
689689
'edit' => 'ویرایش',
690690
'id' => 'شناسه',
691691
'in-stock' => 'در انبار',
692+
'tag-name' => 'نام برچسب',
692693
'name' => 'نام',
693694
'on-hand' => 'موجودی',
694695
'price' => 'قیمت',

packages/Webkul/Admin/src/Resources/lang/pt_BR/app.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,7 @@
683683
'edit' => 'Editar',
684684
'id' => 'ID',
685685
'in-stock' => 'Em Estoque',
686+
'tag-name' => 'Nome da Tag',
686687
'name' => 'Nome',
687688
'on-hand' => 'Disponível',
688689
'price' => 'Preço',

packages/Webkul/Admin/src/Resources/lang/tr/app.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,7 @@
689689
'edit' => 'Düzenle',
690690
'id' => 'ID',
691691
'in-stock' => 'Stokta',
692+
'tag-name' => 'Etiket Adı',
692693
'name' => 'Ad',
693694
'on-hand' => 'Elinde',
694695
'price' => 'Fiyat',

packages/Webkul/Admin/src/Resources/lang/vi/app.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,7 @@
686686
'edit' => 'Chỉnh sửa',
687687
'id' => 'ID',
688688
'in-stock' => 'Có sẵn',
689+
'tag-name' => 'Tên thẻ',
689690
'name' => 'Tên',
690691
'on-hand' => 'Sẵn có',
691692
'price' => 'Giá',

0 commit comments

Comments
 (0)