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/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/Repositories/BulkProductRepository.php b/src/Repositories/BulkProductRepository.php index f8d9d18..026929e 100644 --- a/src/Repositories/BulkProductRepository.php +++ b/src/Repositories/BulkProductRepository.php @@ -199,7 +199,7 @@ public function productRepositoryUpdateForVariants(array $data, $id, $attribute $this->productInventoryRepository->saveInventories($data, $product); - $this->productImageRepository->uploadImages($data, $product); + // $this->productImageRepository->uploadImages($data, $product); } if (isset($data['channels'])) { 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); 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 c82a38f..5f68c3f 100644 --- a/src/Repositories/Products/ConfigurableProductRepository.php +++ b/src/Repositories/Products/ConfigurableProductRepository.php @@ -497,6 +497,44 @@ public function createProduct($requestData, $imageZipName, $product) $data['weight'] = (string)$csvData[$i]['super_attribute_weight']; $data['status'] = (string)$csvData[$i]['status']; + //Variant Product Images + $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[$i]['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; + } + } + } + + if (isset($imageZipName)) { + $this->productImageRepository->bulkuploadImages($data, $configSimpleproduct, $imageZipName); + } else if (isset($csvData[$i]['images'])) { + $this->productImageRepository->bulkuploadImages($data, $configSimpleproduct, $imageZipName = null); + } + if ( isset($data['super_attributes'])) { foreach ($data['super_attributes'] as $attributeCode => $attributeOptions) { $attribute = $this->attributeRepository->findOneByField('code', $attributeCode); 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') }} +