From f3e3415619bf335810c52961f639862a076e1677 Mon Sep 17 00:00:00 2001 From: prateek srivastava Date: Mon, 13 Dec 2021 13:06:35 +0530 Subject: [PATCH 1/8] issue #67 fixed --- src/Providers/BulkUploadServiceProvider.php | 6 ++- .../bulk-upload/layouts/nav-aside.blade.php | 41 +++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 src/Resources/views/admin/bulk-upload/layouts/nav-aside.blade.php diff --git a/src/Providers/BulkUploadServiceProvider.php b/src/Providers/BulkUploadServiceProvider.php index 0720fc9..8127c58 100644 --- a/src/Providers/BulkUploadServiceProvider.php +++ b/src/Providers/BulkUploadServiceProvider.php @@ -23,6 +23,10 @@ public function boot() __DIR__ . '/../../publishable/assets' => public_path('themes/default/assets'), ], 'public'); + $this->publishes([ + __DIR__ . '/../Resources/views/admin/bulk-upload/layouts/nav-aside.blade.php' => resource_path('views/vendor/admin/layouts/nav-aside.blade.php'), + ]); + view()->composer(['bulkupload::admin.bulk-upload.upload-files.index'], function ($view) { $items = []; @@ -58,7 +62,7 @@ protected function registerConfig() $this->mergeConfigFrom( dirname(__DIR__) . '/Config/system.php', 'core' ); - + $this->mergeConfigFrom( dirname(__DIR__) . '/Config/admin-menu.php', 'menu.admin' ); diff --git a/src/Resources/views/admin/bulk-upload/layouts/nav-aside.blade.php b/src/Resources/views/admin/bulk-upload/layouts/nav-aside.blade.php new file mode 100644 index 0000000..e7f431d --- /dev/null +++ b/src/Resources/views/admin/bulk-upload/layouts/nav-aside.blade.php @@ -0,0 +1,41 @@ +
+ + {{-- button for collapsing aside nav --}} + + + +
From 692ceb765c6a45b50f1f76c9b87a2350ec708d9f Mon Sep 17 00:00:00 2001 From: anmol chauhan Date: Tue, 21 Dec 2021 10:48:57 +0530 Subject: [PATCH 2/8] Issue was in uploading image zip file --- src/Repositories/ProductImageRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Repositories/ProductImageRepository.php b/src/Repositories/ProductImageRepository.php index c290c74..3614913 100644 --- a/src/Repositories/ProductImageRepository.php +++ b/src/Repositories/ProductImageRepository.php @@ -80,7 +80,7 @@ public function bulkuploadImages($data, $product, $imageZipName) { if (isset($data['images'])) { foreach($data['images'] as $key => $value) { - if (is_null($imageZipName)) { + if ( ! is_null($imageZipName)) { $files = "imported-products/extracted-images/admin/".$data['dataFlowProfileRecordId'].'/'. $imageZipName['dirname'].'/'.basename($value); } else { $files = "imported-products/extracted-images/admin/".$data['dataFlowProfileRecordId'].'/'.basename($value); From 9cf85f5bc88517183db37407e73187f74d73f0c8 Mon Sep 17 00:00:00 2001 From: prateek srivastava Date: Tue, 28 Dec 2021 13:21:17 +0530 Subject: [PATCH 3/8] issue #39 fixed --- .../ConfigurableProductRepository.php | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/Repositories/Products/ConfigurableProductRepository.php b/src/Repositories/Products/ConfigurableProductRepository.php index c82a38f..d0f3b05 100644 --- a/src/Repositories/Products/ConfigurableProductRepository.php +++ b/src/Repositories/Products/ConfigurableProductRepository.php @@ -238,7 +238,7 @@ public function createProduct($requestData, $imageZipName, $product) $attributeOption = $this->attributeOptionRepository->findOneByField('admin_name', $csvData[$i][$searchIndex]); array_push($attributeValue, (isset($attributeOption['id']) ? $attributeOption['id'] : null)); - + } else if ($value['type'] == "checkbox") { $attributeOption = $this->attributeOptionRepository->findOneWhere([ 'attribute_id' => $value['id'], @@ -512,8 +512,45 @@ public function createProduct($requestData, $imageZipName, $product) } } + $individualProductimages = explode(',', $csvData[$i]['images']); + + if (isset($imageZipName)) { + $images = Storage::disk('local')->files('public/imported-products/extracted-images/admin/'.$dataFlowProfileRecord->id.'/'.$imageZipName['dirname'].'/'); + + foreach ($images as $imageArraykey => $imagePath) { + $imageName = explode('/', $imagePath); + + if (in_array(last($imageName), preg_replace('/[\'"]/', '',$individualProductimages))) { + $data['images'][$imageArraykey] = $imagePath; + } + } + } else if (isset($csvData['images'])) { + foreach ($individualProductimages as $imageArraykey => $imageURL) + { + if (filter_var(trim($imageURL), FILTER_VALIDATE_URL)) { + $imagePath = storage_path('app/public/ imported-products/extracted-images/admin/'. $dataFlowProfileRecord->id); + + if (!file_exists($imagePath)) { + mkdir($imagePath, 0777, true); + } + + $imageFile = $imagePath.'/'.basename($imageURL) ; + + file_put_contents($imageFile, file_get_contents (trim($imageURL))); + + $data['images'][$imageArraykey] = $imageFile; + } + } + } + $configSimpleProductAttributeStore = $this->bulkProductRepository->productRepositoryUpdateForVariants($data, $configSimpleproduct->id); + if (isset($imageZipName)) { + $this->productImageRepository->bulkuploadImages($data, $configSimpleproduct, $imageZipName); + } else if (isset($csvData['images'])) { + $this->productImageRepository->bulkuploadImages($data, $configSimpleproduct, $imageZipName = null); + } + $configSimpleProductAttributeStore['parent_id'] = $product['productFlatId']; $this->createFlat($configSimpleProductAttributeStore); From 1d0af75cc501b5e5bfca8ad8837b9490e5f3dbe4 Mon Sep 17 00:00:00 2001 From: prateek srivastava Date: Tue, 28 Dec 2021 15:47:15 +0530 Subject: [PATCH 4/8] issue #44 fixed --- src/DataGrids/Admin/ProfileDataGrid.php | 11 ++++++- ...er_bulkupload_data_flow_profiles_table.php | 30 +++++++++++++++++++ .../Admin/BulkUploadController.php | 5 +++- .../Products/BookingProductRepository.php | 4 ++- .../Products/BundledProductRepository.php | 4 ++- .../ConfigurableProductRepository.php | 9 ++++-- .../DownloadableProductRepository.php | 4 ++- .../Products/GroupedProductRepository.php | 4 ++- .../Products/SimpleProductRepository.php | 5 +++- .../Products/VirtualProductRepository.php | 4 ++- src/Resources/lang/en/app.php | 3 +- .../data-flow-profile/index.blade.php | 13 ++++++++ 12 files changed, 85 insertions(+), 11 deletions(-) create mode 100644 src/Database/Migrations/2021_12_28_150311_alter_bulkupload_data_flow_profiles_table.php diff --git a/src/DataGrids/Admin/ProfileDataGrid.php b/src/DataGrids/Admin/ProfileDataGrid.php index eecbb43..f0c9404 100644 --- a/src/DataGrids/Admin/ProfileDataGrid.php +++ b/src/DataGrids/Admin/ProfileDataGrid.php @@ -21,7 +21,7 @@ public function prepareQueryBuilder() $queryBuilder = DB::table('bulkupload_data_flow_profiles') ->leftJoin('attribute_families', 'bulkupload_data_flow_profiles.attribute_family_id', '=', 'attribute_families.id') ->select('bulkupload_data_flow_profiles.id', - 'bulkupload_data_flow_profiles.name as profile_name', 'attribute_families.name', 'bulkupload_data_flow_profiles.created_at'); + 'bulkupload_data_flow_profiles.name as profile_name', 'attribute_families.name', 'bulkupload_data_flow_profiles.locale_code', 'bulkupload_data_flow_profiles.created_at'); $this->addFilter('created_at', 'bulkupload_data_flow_profiles.created_at'); $this->addFilter('profile_name', 'bulkupload_data_flow_profiles.name'); @@ -50,6 +50,15 @@ public function addColumns() 'filterable' => true ]); + $this->addColumn([ + 'index' => 'locale_code', + 'label' => trans('bulkupload::app.admin.bulk-upload.data-flow-profile.data-grid.locale_code'), + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true + ]); + $this->addColumn([ 'index' => 'created_at', 'label' => trans('bulkupload::app.admin.bulk-upload.data-flow-profile.data-grid.created-at'), diff --git a/src/Database/Migrations/2021_12_28_150311_alter_bulkupload_data_flow_profiles_table.php b/src/Database/Migrations/2021_12_28_150311_alter_bulkupload_data_flow_profiles_table.php new file mode 100644 index 0000000..7d0e24e --- /dev/null +++ b/src/Database/Migrations/2021_12_28_150311_alter_bulkupload_data_flow_profiles_table.php @@ -0,0 +1,30 @@ +string('locale_code'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} diff --git a/src/Http/Controllers/Admin/BulkUploadController.php b/src/Http/Controllers/Admin/BulkUploadController.php index 088092e..62966a1 100644 --- a/src/Http/Controllers/Admin/BulkUploadController.php +++ b/src/Http/Controllers/Admin/BulkUploadController.php @@ -102,11 +102,14 @@ public function store() { request()->validate([ 'name' => 'required|unique:bulkupload_data_flow_profiles', - 'attribute_family' => 'required' + 'attribute_family' => 'required', + 'locale_code' => 'required' ]); $dataFlowProfileAdmin['name'] = request()->name; $dataFlowProfileAdmin['attribute_family_id'] = request()->attribute_family; + $dataFlowProfileAdmin['locale_code'] = request()->locale_code; + $this->dataFlowProfileRepository->create($dataFlowProfileAdmin); diff --git a/src/Repositories/Products/BookingProductRepository.php b/src/Repositories/Products/BookingProductRepository.php index 6ca76fb..ff56602 100644 --- a/src/Repositories/Products/BookingProductRepository.php +++ b/src/Repositories/Products/BookingProductRepository.php @@ -316,7 +316,9 @@ public function store($csvData, $i, $dataFlowProfileRecord, $requestData, $image $data['categories'] = $categoryID; $data['channel'] = core()->getCurrentChannel()->code; - $data['locale'] = core()->getDefaultChannel()->default_locale->code; + + $dataProfile = app('Webkul\Bulkupload\Repositories\DataFlowProfileRepository')->findOneByfield(['id' => $data['dataFlowProfileRecordId']]); + $data['locale'] = $dataProfile->locale_code; //customerGroupPricing if (isset($csvData['customer_group_prices']) && ! empty($csvData['customer_group_prices'])) { diff --git a/src/Repositories/Products/BundledProductRepository.php b/src/Repositories/Products/BundledProductRepository.php index d6d1b09..48ab5d5 100644 --- a/src/Repositories/Products/BundledProductRepository.php +++ b/src/Repositories/Products/BundledProductRepository.php @@ -309,7 +309,9 @@ public function store($csvData, $i, $dataFlowProfileRecord, $requestData, $image $data['categories'] = $categoryID; $data['channel'] = core()->getCurrentChannel()->code; - $data['locale'] = core()->getDefaultChannel()->default_locale->code; + + $dataProfile = app('Webkul\Bulkupload\Repositories\DataFlowProfileRepository')->findOneByfield(['id' => $data['dataFlowProfileRecordId']]); + $data['locale'] = $dataProfile->locale_code; //customerGroupPricing if (isset($csvData['customer_group_prices']) && ! empty($csvData['customer_group_prices'])) { diff --git a/src/Repositories/Products/ConfigurableProductRepository.php b/src/Repositories/Products/ConfigurableProductRepository.php index d0f3b05..06c2aa1 100644 --- a/src/Repositories/Products/ConfigurableProductRepository.php +++ b/src/Repositories/Products/ConfigurableProductRepository.php @@ -260,7 +260,9 @@ public function createProduct($requestData, $imageZipName, $product) $data['dataFlowProfileRecordId'] = $dataFlowProfileRecord->id; $data['channel'] = core()->getCurrentChannel()->code; - $data['locale'] = core()->getDefaultChannel()->default_locale->code; + + $dataProfile = app('Webkul\Bulkupload\Repositories\DataFlowProfileRepository')->findOneByfield(['id' => $data['dataFlowProfileRecordId']]); + $data['locale'] = $dataProfile->locale_code; $data['tax_category_id'] = (isset($csvData[$i]['tax_category_id']) && $csvData[$i]['tax_category_id']) ? $csvData[$i]['tax_category_id'] : null; @@ -475,7 +477,10 @@ public function createProduct($requestData, $imageZipName, $product) } $data['channel'] = core()->getCurrentChannel()->code; - $data['locale'] = core()->getDefaultChannel()->default_locale->code; + + $dataProfile = app('Webkul\Bulkupload\Repositories\DataFlowProfileRepository')->findOneByfield(['id' => $data['dataFlowProfileRecordId']]); + $data['locale'] = $dataProfile->locale_code; + $data['dataFlowProfileRecordId'] = $dataFlowProfileRecord->id; $data['price'] = (string)$csvData[$i]['super_attribute_price']; $data['special_price'] = (string)$csvData[$i]['special_price']; diff --git a/src/Repositories/Products/DownloadableProductRepository.php b/src/Repositories/Products/DownloadableProductRepository.php index 9ee26a6..13f2b29 100644 --- a/src/Repositories/Products/DownloadableProductRepository.php +++ b/src/Repositories/Products/DownloadableProductRepository.php @@ -365,7 +365,9 @@ public function store($csvData, $i, $dataFlowProfileRecord, $requestData, $image $data['categories'] = $categoryID; $data['channel'] = core()->getCurrentChannel()->code; - $data['locale'] = core()->getDefaultChannel()->default_locale->code; + + $dataProfile = app('Webkul\Bulkupload\Repositories\DataFlowProfileRepository')->findOneByfield(['id' => $data['dataFlowProfileRecordId']]); + $data['locale'] = $dataProfile->locale_code; //customerGroupPricing if (isset($csvData['customer_group_prices']) && ! empty($csvData['customer_group_prices'])) { diff --git a/src/Repositories/Products/GroupedProductRepository.php b/src/Repositories/Products/GroupedProductRepository.php index 4cfc1db..c12b99a 100644 --- a/src/Repositories/Products/GroupedProductRepository.php +++ b/src/Repositories/Products/GroupedProductRepository.php @@ -315,7 +315,9 @@ public function store($csvData, $i, $dataFlowProfileRecord, $requestData, $image $data['categories'] = $categoryID; $data['channel'] = core()->getCurrentChannel()->code; - $data['locale'] = core()->getDefaultChannel()->default_locale->code; + + $dataProfile = app('Webkul\Bulkupload\Repositories\DataFlowProfileRepository')->findOneByfield(['id' => $data['dataFlowProfileRecordId']]); + $data['locale'] = $dataProfile->locale_code; //customerGroupPricing if (isset($csvData['customer_group_prices']) && ! empty($csvData['customer_group_prices'])) { diff --git a/src/Repositories/Products/SimpleProductRepository.php b/src/Repositories/Products/SimpleProductRepository.php index 94973ff..07f812e 100644 --- a/src/Repositories/Products/SimpleProductRepository.php +++ b/src/Repositories/Products/SimpleProductRepository.php @@ -358,7 +358,10 @@ public function store($csvData, $i, $dataFlowProfileRecord, $requestData, $image $data['categories'] = $categoryID; $data['channel'] = core()->getCurrentChannel()->code; - $data['locale'] = core()->getDefaultChannel()->default_locale->code; + + $dataProfile = app('Webkul\Bulkupload\Repositories\DataFlowProfileRepository')->findOneByfield(['id' => $data['dataFlowProfileRecordId']]); + + $data['locale'] = $dataProfile->locale_code; //customerGroupPricing if (isset($csvData['customer_group_prices']) && ! empty($csvData['customer_group_prices'])) { diff --git a/src/Repositories/Products/VirtualProductRepository.php b/src/Repositories/Products/VirtualProductRepository.php index 877e9ac..852b973 100644 --- a/src/Repositories/Products/VirtualProductRepository.php +++ b/src/Repositories/Products/VirtualProductRepository.php @@ -346,7 +346,9 @@ public function store($csvData, $i, $dataFlowProfileRecord, $requestData, $image $data['categories'] = $categoryID; $data['channel'] = core()->getCurrentChannel()->code; - $data['locale'] = core()->getDefaultChannel()->default_locale->code; + + $dataProfile = app('Webkul\Bulkupload\Repositories\DataFlowProfileRepository')->findOneByfield(['id' => $data['dataFlowProfileRecordId']]); + $data['locale'] = $dataProfile->locale_code; //customerGroupPricing if (isset($csvData['customer_group_prices']) && ! empty($csvData['customer_group_prices'])) { diff --git a/src/Resources/lang/en/app.php b/src/Resources/lang/en/app.php index 9090e56..09ba67a 100644 --- a/src/Resources/lang/en/app.php +++ b/src/Resources/lang/en/app.php @@ -22,7 +22,8 @@ 'update-profile' => 'Update', 'data-grid' => [ - 'created-at' => 'Created At' + 'created-at' => 'Created At', + 'locale_code' => 'Locale code' ] ], diff --git a/src/Resources/views/admin/bulk-upload/data-flow-profile/index.blade.php b/src/Resources/views/admin/bulk-upload/data-flow-profile/index.blade.php index d41e24e..c2d6b76 100644 --- a/src/Resources/views/admin/bulk-upload/data-flow-profile/index.blade.php +++ b/src/Resources/views/admin/bulk-upload/data-flow-profile/index.blade.php @@ -42,6 +42,19 @@ {{ $errors->first('attribute_family') }} +
+ + + + @{{ errors.first('locale_code') }} +
+