diff --git a/README.md b/README.md index 28af95aee..d7f8566a2 100755 --- a/README.md +++ b/README.md @@ -60,8 +60,8 @@ Bagisto is using power of both of these frameworks and making best out of it out ### Requirements -* **OS**: Ubuntu 16.04 LTS or higher. -* **SERVER**: Apache 2 or NGINX +* **OS**: Ubuntu 16.04 LTS or higher / Windows 7 or Higher (WAMP / XAMP). +* **SERVER**: Apache 2 or NGINX. * **RAM**: 3 GB or higher. * **PHP**: 7.1.17 or higher. * **Processor**: Clock Cycle 1 Ghz or higher. @@ -76,7 +76,7 @@ Bagisto is using power of both of these frameworks and making best out of it out ##### a. Download zip from the link below: -[Download](https://github.com/bagisto/bagisto/archive/v0.1.5.zip) +[Download](https://github.com/bagisto/bagisto/archive/v0.1.6.zip) ##### b. Extract the contents of zip and execute the project in browser: diff --git a/packages/Webkul/Admin/src/DataGrids/CMSPageDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CMSPageDataGrid.php index c599e226b..3212e05e5 100644 --- a/packages/Webkul/Admin/src/DataGrids/CMSPageDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CMSPageDataGrid.php @@ -101,4 +101,14 @@ class CMSPageDataGrid extends DataGrid 'icon' => 'icon trash-icon' ]); } + + public function prepareMassActions() + { + $this->addMassAction([ + 'type' => 'delete', + 'label' => 'Delete', + 'action' => route('admin.cms.mass-delete'), + 'method' => 'DELETE' + ]); + } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/Http/routes.php b/packages/Webkul/Admin/src/Http/routes.php index 1b2ac572b..5782bbf7e 100755 --- a/packages/Webkul/Admin/src/Http/routes.php +++ b/packages/Webkul/Admin/src/Http/routes.php @@ -508,21 +508,6 @@ Route::group(['middleware' => ['web']], function () { Route::put('/account', 'Webkul\User\Http\Controllers\AccountController@update')->name('admin.account.update'); - //API Authorizations - // Route::get('/api/clients', 'Webkul\Admin\Http\Controllers\AuthorizationController@show')->defaults('_config', [ - // 'view' => 'admin::apiauth.client' - // ])->name('admin.index.oauth.client'); - - // //view an OAuth API Client - // Route::get('/api/clients/view/{id}', 'Webkul\Admin\Http\Controllers\AuthorizationController@view')->defaults('_config', [ - // 'view' => 'admin::apiauth.view' - // ])->name('admin.view.oauth.client'); - - // //edit an OAuth API Client - // Route::get('/api/clients/delete/{id}', 'Webkul\Admin\Http\Controllers\AuthorizationController@delete')->defaults('_config', [ - // 'view' => 'admin::apiauth.edit' - // ])->name('admin.delete.oauth.client'); - // Admin Store Front Settings Route Route::get('/subscribers','Webkul\Core\Http\Controllers\SubscriptionController@index')->defaults('_config',[ @@ -704,6 +689,14 @@ Route::group(['middleware' => ['web']], function () { Route::post('/delete/{id}', 'Webkul\CMS\Http\Controllers\Admin\PageController@delete')->defaults('_config', [ 'redirect' => 'admin.cms.index' ])->name('admin.cms.delete'); + + Route::post('/massdelete', 'Webkul\CMS\Http\Controllers\Admin\PageController@massDelete')->defaults('_config', [ + 'redirect' => 'admin.cms.index' + ])->name('admin.cms.mass-delete'); + + // Route::post('/delete/{id}', 'Webkul\CMS\Http\Controllers\Admin\PageController@delete')->defaults('_config', [ + // 'redirect' => 'admin.cms.index' + // ])->name('admin.cms.delete'); }); }); }); diff --git a/packages/Webkul/Admin/src/Resources/lang/en/app.php b/packages/Webkul/Admin/src/Resources/lang/en/app.php index db16f2c1a..5be44fd1f 100755 --- a/packages/Webkul/Admin/src/Resources/lang/en/app.php +++ b/packages/Webkul/Admin/src/Resources/lang/en/app.php @@ -108,6 +108,7 @@ return [ 'delete-success' => 'Selected index of :resource were successfully deleted', 'partial-action' => 'Some actions were not performed due restricted system constraints on :resource', 'update-success' => 'Selected index of :resource were successfully updated', + 'no-resource' => 'The resource provided for insufficient for the action' ], 'id' => 'ID', diff --git a/packages/Webkul/CMS/src/Http/Controllers/Admin/PageController.php b/packages/Webkul/CMS/src/Http/Controllers/Admin/PageController.php index 2899c996b..d635fb763 100644 --- a/packages/Webkul/CMS/src/Http/Controllers/Admin/PageController.php +++ b/packages/Webkul/CMS/src/Http/Controllers/Admin/PageController.php @@ -234,4 +234,45 @@ use Webkul\Core\Repositories\LocaleRepository as Locale; return response()->json(['message' => false], 200); } } + + /** + * To mass delete the CMS resource from storage + */ + public function massDelete() + { + $data = request()->all(); + + if ($data['indexes']) { + $pageIDs = explode(',', $data['indexes']); + + $actualCount = count($pageIDs); + + $count = 0; + + foreach ($pageIDs as $pageId) { + + $page = $this->cms->find($pageId); + + if ($page) { + $page->delete(); + + $count++; + } + } + + if ($actualCount == $count) { + session()->flash('success', trans('admin::app.datagrid.mass-ops.delete-success', [ + 'resource' => 'CMS Pages' + ])); + } else { + session()->flash('success', trans('admin::app.datagrid.mass-ops.partial-action', [ + 'resource' => 'CMS Pages' + ])); + } + } else { + session()->flash('warning', trans('admin::app.datagrid.mass-ops.no-resource')); + } + + return redirect()->route('admin.cms.index'); + } } \ No newline at end of file diff --git a/packages/Webkul/Discount/src/Helpers/Catalog/Apply.php b/packages/Webkul/Discount/src/Helpers/Catalog/Apply.php index 7f7b4e6e8..823c3df24 100644 --- a/packages/Webkul/Discount/src/Helpers/Catalog/Apply.php +++ b/packages/Webkul/Discount/src/Helpers/Catalog/Apply.php @@ -64,6 +64,8 @@ class Apply extends Sale $this->active = collect(); + $this->activeRules = collect(); + $this->deceased = collect(); $this->rules = config('discount-rules.catalog'); @@ -82,10 +84,7 @@ class Apply extends Sale if ($validated) { $this->active->push($rule->id); - // Job execution for active rules - $productIDs = $this->getProductIds($rule); - - $this->setSale($rule, $productIDs); + $this->activeRules->push($rule); } else { $this->deceased->push($rule->id); @@ -93,7 +92,15 @@ class Apply extends Sale } } - dd('done'); + if ($this->active->count()) { + foreach ($this->activeRules as $rule) { + $productIDs = $this->getProductIds($rule); + + $this->setSale($rule, $productIDs); + } + } else { + dd($this->deceased); + } } /** @@ -105,12 +112,14 @@ class Apply extends Sale */ public function setSale($rule, $productIDs) { + dd($productIDs); + if (is_array($productIDs)) { // apply on selected products foreach ($productIDs as $productID) { - $this->catalogRuleProduct->createOrUpdate($rule, $productID); + // $this->catalogRuleProduct->createOrUpdate($rule, $productID); - $this->catalogRuleProductPrice->createOrUpdate($rule, $productID); + // $this->catalogRuleProductPrice->createOrUpdate($rule, $productID); } } else if ($productIDs == '*') { $this->catalogRuleProduct->createOrUpdate($rule, $productIDs); diff --git a/packages/Webkul/Discount/src/Helpers/Catalog/ConvertXToProductId.php b/packages/Webkul/Discount/src/Helpers/Catalog/ConvertXToProductId.php index ff346b2db..6c1e3c632 100644 --- a/packages/Webkul/Discount/src/Helpers/Catalog/ConvertXToProductId.php +++ b/packages/Webkul/Discount/src/Helpers/Catalog/ConvertXToProductId.php @@ -193,6 +193,7 @@ class ConvertXToProductId foreach ($categories as $category) { $data = $this->getAll($category->id); + if ($data->count()) { $products->push($data); @@ -249,7 +250,6 @@ class ConvertXToProductId ->select('products.id') ->leftJoin('products', 'product_flat.product_id', '=', 'products.id') ->leftJoin('product_categories', 'products.id', '=', 'product_categories.product_id') - ->where('products.type', '!=', 'configurable') ->whereNotNull('product_flat.url_key'); if ($categoryId) { diff --git a/packages/Webkul/Discount/src/Repositories/CatalogRuleProductsRepository.php b/packages/Webkul/Discount/src/Repositories/CatalogRuleProductsRepository.php index 959569d1a..609a1ea83 100644 --- a/packages/Webkul/Discount/src/Repositories/CatalogRuleProductsRepository.php +++ b/packages/Webkul/Discount/src/Repositories/CatalogRuleProductsRepository.php @@ -49,10 +49,48 @@ class CatalogRuleProductsRepository extends Repository if ($productID == '*') { $products = $this->product->all('id'); - // for all products do that thing later - } else { - $product = $this->product->find($productID); + foreach ($channelsGroupsCross as $channelGroup) { + $channelId = $channelGroup[0]->channel_id; + $groupId = $channelGroup[1]->customer_group_id; + $model = new $this->model(); + + foreach ($products as $product) { + $productID = $product->id; + + $catalogRuleProduct = $model->where([ + 'channel_id' => $channelId, + 'customer_group_id' => $groupId, + 'product_id' => $productID + ])->get(); + + if ($catalogRuleProduct->count()) { + // check for tie breaker rules and then update + $catalogRuleProduct->first()->update([ + 'catalog_rule_id' => $rule->id, + 'starts_from' => $rule->starts_from, + 'ends_till' => $rule->ends_till, + 'customer_group_id' => $groupId, + 'channel_id' => $channelId, + 'product_id' => $productID, + 'action_code' => $rule->action_code, + 'action_amount' => $rule->discount_amount + ]); + } else { + $this->create([ + 'catalog_rule_id' => $rule->id, + 'starts_from' => $rule->starts_from, + 'ends_till' => $rule->ends_till, + 'customer_group_id' => $groupId, + 'channel_id' => $channelId, + 'product_id' => $productID, + 'action_code' => $rule->action_code, + 'action_amount' => $rule->discount_amount + ]); + } + } + } + } else { foreach ($channelsGroupsCross as $channelGroup) { $channelId = $channelGroup[0]->channel_id; $groupId = $channelGroup[1]->customer_group_id;