CMS Bug fixes and updated readme

This commit is contained in:
Prashant Singh 2019-08-17 15:42:24 +05:30
parent eb2f805057
commit bb972c6e48
8 changed files with 121 additions and 29 deletions

View File

@ -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:

View File

@ -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'
]);
}
}

View File

@ -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');
});
});
});

View File

@ -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',

View File

@ -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');
}
}

View File

@ -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);

View File

@ -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) {

View File

@ -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;