diff --git a/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php index 111b1fd18..f32bd3262 100755 --- a/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php @@ -22,8 +22,12 @@ class CategoryDataGrid extends DataGrid public function prepareQueryBuilder() { $queryBuilder = DB::table('categories as cat') - ->select('cat.id as category_id', 'ct.name', 'cat.position', 'cat.status', 'ct.locale') - ->leftJoin('category_translations as ct', 'cat.id', '=', 'ct.category_id'); + ->select('cat.id as category_id', 'ct.name', 'cat.position', 'cat.status', 'ct.locale', + DB::raw('COUNT(DISTINCT pc.product_id) as count')) + ->leftJoin('category_translations as ct', 'cat.id', '=', 'ct.category_id') + ->leftJoin('product_categories as pc', 'cat.id', '=', 'pc.category_id') + ->groupBy('cat.id'); + $this->addFilter('category_id', 'cat.id'); @@ -77,6 +81,14 @@ class CategoryDataGrid extends DataGrid 'sortable' => true, 'searchable' => true, ]); + + $this->addColumn([ + 'index' => 'count', + 'label' => trans('admin::app.datagrid.no-of-products'), + 'type' => 'number', + 'sortable' => true, + 'searchable' => true, + ]); } public function prepareActions() { diff --git a/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerGroupController.php b/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerGroupController.php index 91f1f332c..b9f16e8ab 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerGroupController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerGroupController.php @@ -131,6 +131,8 @@ class CustomerGroupController extends Controller if ($group->is_user_defined == 0) { session()->flash('warning', trans('admin::app.customers.customers.group-default')); + } else if (count($group->customer) > 0) { + session()->flash('warning', trans('admin::app.response.customer-associate', ['name' => 'Customer Group'])); } else { session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Customer Group'])); diff --git a/packages/Webkul/Admin/src/Resources/lang/en/app.php b/packages/Webkul/Admin/src/Resources/lang/en/app.php index 49c5c6f4c..dedef9fd9 100755 --- a/packages/Webkul/Admin/src/Resources/lang/en/app.php +++ b/packages/Webkul/Admin/src/Resources/lang/en/app.php @@ -145,7 +145,8 @@ return [ 'country' => 'Country', 'tax-rate' => 'Rate', 'role' => 'Role', - 'sub-total' => 'Sub Total' + 'sub-total' => 'Sub Total', + 'no-of-products' => 'Number of Products', ], 'account' => [ @@ -755,6 +756,7 @@ return [ 'last-delete-error' => 'At least one :name is required.', 'user-define-error' => 'Can not delete system :name', 'attribute-error' => ':name is used in configurable products.', - 'attribute-product-error' => ':name is used in products.' + 'attribute-product-error' => ':name is used in products.', + 'customer-associate' => ':name can not be deleted because customer is associated with this group.' ], ]; \ No newline at end of file diff --git a/packages/Webkul/Customer/src/Models/CustomerGroup.php b/packages/Webkul/Customer/src/Models/CustomerGroup.php index 79c51c298..45b9f848b 100755 --- a/packages/Webkul/Customer/src/Models/CustomerGroup.php +++ b/packages/Webkul/Customer/src/Models/CustomerGroup.php @@ -2,10 +2,19 @@ namespace Webkul\Customer\Models; use Illuminate\Database\Eloquent\Model; +use Webkul\Customer\Models\Customer; class CustomerGroup extends Model { protected $table = 'customer_groups'; protected $fillable = ['name', 'is_user_defined']; + + /** + * Get the customer for this group. + */ + public function customer() + { + return $this->hasMany(Customer::class); + } } diff --git a/packages/Webkul/Product/src/Helpers/View.php b/packages/Webkul/Product/src/Helpers/View.php index 87e67842b..26d887b84 100755 --- a/packages/Webkul/Product/src/Helpers/View.php +++ b/packages/Webkul/Product/src/Helpers/View.php @@ -16,13 +16,25 @@ class View extends AbstractProduct $attributes = $product->attribute_family->custom_attributes; + $attributeOptionReposotory = app('Webkul\Attribute\Repositories\AttributeOptionRepository'); + foreach ($attributes as $attribute) { if ($attribute->is_visible_on_front && $product->{$attribute->code}) { + $value = $product->{$attribute->code}; + + if ($attribute->type == 'select') { + $attributeOption = $attributeOptionReposotory->find($value); + + if ($attributeOption) { + $value = $attributeOption->translate(app()->getLocale())->label; + } + } + $data[] = [ 'code' => $attribute->code, 'label' => $attribute->name, - 'value' => $product->{$attribute->code}, - ]; + 'value' => $value, + ]; } } diff --git a/packages/Webkul/Shop/src/Resources/views/layouts/header/index.blade.php b/packages/Webkul/Shop/src/Resources/views/layouts/header/index.blade.php index 59c6780e5..8764994b6 100755 --- a/packages/Webkul/Shop/src/Resources/views/layouts/header/index.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/layouts/header/index.blade.php @@ -30,7 +30,6 @@
- - {{--
- @if (core()->getCurrentChannel()->currencies->count() > 1) - - @endif - - - - -
--}} -
@@ -202,7 +126,6 @@
- @push('scripts')