Created a command to activate the usage of catalog rule
This commit is contained in:
parent
2a6e43de28
commit
9f9e0b6a68
|
|
@ -819,6 +819,9 @@ return [
|
|||
'select-products' => 'How to choose products ?',
|
||||
'select-category' => 'Select by Categories',
|
||||
'select-attribute' => 'Select by Attributes',
|
||||
'cannot-activate-catalog-rule' => 'Cannot activate catalog rule',
|
||||
'catalog-rule-already-activated' => 'Catalog rule is already activated',
|
||||
'catalog-rule-activated' => 'Catalog rule is activated',
|
||||
'general-info' => [
|
||||
'sku-like' => 'SKU Like',
|
||||
'on-shipping' => 'If applied on shipping',
|
||||
|
|
|
|||
|
|
@ -363,7 +363,7 @@
|
|||
</select>
|
||||
|
||||
<div v-if='attribute_list[index].type == "select" || attribute_list[index].type == "multiselect"' style="display: flex; width: 220px">
|
||||
<multiselect v-model="attribute_list[index].value" :options="dummy_options" :searchable="false" :show-labels="true" placeholder="Select Categories" :multiple="true"></multiselect>
|
||||
<multiselect v-model="attribute_list[index].value" :options="attribute_list[index].options" :custom-label="attributeListLabel(index)" :track-by="attribute_list[index].options.admin_name" :searchable="false" :show-labels="true" placeholder="{{ __('ui::form.select-attribute', ['attribute' => 'Values']) }}" :multiple="true"></multiselect>
|
||||
</div>
|
||||
|
||||
<div v-if='attribute_list[index].type == "text" || attribute_list[index].type == "textarea" || attribute_list[index].type == "price" || attribute_list[index].type == "textarea"' style="display: flex">
|
||||
|
|
@ -416,9 +416,6 @@
|
|||
|
||||
data () {
|
||||
return {
|
||||
dummy_options: [
|
||||
1, 2, 3, 4, 5
|
||||
],
|
||||
name: null,
|
||||
description: null,
|
||||
conditions_list: [],
|
||||
|
|
@ -483,7 +480,8 @@
|
|||
attr_object: {
|
||||
attribute: null,
|
||||
condition: null,
|
||||
value: []
|
||||
value: [],
|
||||
options: []
|
||||
},
|
||||
attribute_input: @json($cart_rule[3]),
|
||||
attribute_options: [],
|
||||
|
|
@ -500,6 +498,10 @@
|
|||
return attribute_options.name + ' [ ' + attribute_options.type + ' ]';
|
||||
},
|
||||
|
||||
attributeListLabel (index) {
|
||||
console.log(this.attribute_list[index], index);
|
||||
},
|
||||
|
||||
addCondition () {
|
||||
if (this.criteria == 'product_subselection' || this.criteria == 'cart') {
|
||||
this.condition_on = this.criteria;
|
||||
|
|
@ -526,7 +528,8 @@
|
|||
this.attr_object = {
|
||||
attribute: null,
|
||||
condition: null,
|
||||
value: []
|
||||
value: [],
|
||||
options: []
|
||||
};
|
||||
},
|
||||
|
||||
|
|
@ -558,8 +561,11 @@
|
|||
|
||||
for(i in this.attribute_input) {
|
||||
if (i == selectedIndex) {
|
||||
if (this.attribute_input[i].has_options == true) {
|
||||
this.attribute_input[i].options = this.attribute_input[i].options;
|
||||
}
|
||||
|
||||
this.attribute_list[index].type = this.attribute_input[i].type;
|
||||
console.log(this.attribute_list[index].type);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class AttributeTableSeeder extends Seeder
|
|||
['id' => '10','code' => 'description','admin_name' => 'Description','type' => 'textarea','validation' => NULL,'position' => '10','is_required' => '1','is_unique' => '0','value_per_locale' => '1','value_per_channel' => '1','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0','created_at' => $now,'updated_at' => $now],
|
||||
['id' => '11','code' => 'price','admin_name' => 'Price','type' => 'price','validation' => 'decimal','position' => '11','is_required' => '1','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '1','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0','created_at' => $now,'updated_at' => $now],
|
||||
['id' => '12','code' => 'cost','admin_name' => 'Cost','type' => 'price','validation' => 'decimal','position' => '12','is_required' => '0','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '1','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '1','is_visible_on_front' => '0','created_at' => $now,'updated_at' => $now],
|
||||
['id' => '13','code' => 'special_price','admin_name' => 'Special Price','type' => 'price','validation' => 'decimal','position' => '13','is_required' => '0','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0','created_at' => $now,'updated_at' => $now],
|
||||
['id' => '13','code' => 'special_price','admin_name' => 'Special Price','type' => 'price','validation' => 'decimal','position' => '13','is_required' => '0','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '1','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0','created_at' => $now,'updated_at' => $now],
|
||||
['id' => '14','code' => 'special_price_from','admin_name' => 'Special Price From','type' => 'date','validation' => NULL,'position' => '14','is_required' => '0','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '1','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0','created_at' => $now,'updated_at' => $now],
|
||||
['id' => '15','code' => 'special_price_to','admin_name' => 'Special Price To','type' => 'date','validation' => NULL,'position' => '15','is_required' => '0','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '1','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0','created_at' => $now,'updated_at' => $now],
|
||||
['id' => '16','code' => 'meta_title','admin_name' => 'Meta Title','type' => 'textarea','validation' => NULL,'position' => '16','is_required' => '0','is_unique' => '0','value_per_locale' => '1','value_per_channel' => '1','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0','created_at' => $now,'updated_at' => $now],
|
||||
|
|
|
|||
|
|
@ -221,12 +221,26 @@ class AttributeRepository extends Repository
|
|||
|
||||
foreach($attributes as $key => $attribute) {
|
||||
if ($attribute->code != 'tax_category_id' && ($attribute->type == 'select' || $attribute->type == 'multiselect' || $attribute->code == 'sku')) {
|
||||
array_push($trimmed, [
|
||||
'id' => $attribute->id,
|
||||
'name' => $attribute->name,
|
||||
'type' => $attribute->type,
|
||||
'code' => $attribute->code,
|
||||
]);
|
||||
if ($attribute->options()->exists()) {
|
||||
array_push($trimmed, [
|
||||
'id' => $attribute->id,
|
||||
'name' => $attribute->name,
|
||||
'type' => $attribute->type,
|
||||
'code' => $attribute->code,
|
||||
'has_options' => true,
|
||||
'options' => $attribute->options
|
||||
]);
|
||||
} else {
|
||||
array_push($trimmed, [
|
||||
'id' => $attribute->id,
|
||||
'name' => $attribute->name,
|
||||
'type' => $attribute->type,
|
||||
'code' => $attribute->code,
|
||||
'has_options' => false,
|
||||
'options' => null
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Discount\Commands\Console;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Webkul\Attribute\Repositories\AttributeRepository as Attribute;
|
||||
|
||||
class ActivateCatalogRule extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'bagisto:activate {param}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description;
|
||||
|
||||
/**
|
||||
* To hold attribute repository instance
|
||||
*/
|
||||
protected $attribute;
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Attribute $attribute)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->attribute = $attribute;
|
||||
|
||||
$this->description = trans('admin::app.promotion.activate-catalog');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$param = $this->argument('param');
|
||||
|
||||
if (isset($param) && $param == 'catalog-rule') {
|
||||
$attribute = $this->attribute->findWhere([
|
||||
'code' => 'special_price'
|
||||
]);
|
||||
|
||||
if ($attribute->count()) {
|
||||
$attribute = $attribute->first();
|
||||
|
||||
if ($attribute->value_per_channel == 1) {
|
||||
$this->info(trans('admin::app.promotion.catalog-rule-already-activated'));
|
||||
} else {
|
||||
$attribute->update(['value_per_channel' => 1]);
|
||||
|
||||
$this->info(trans('admin::app.promotion.catalog-rule-activated'));
|
||||
}
|
||||
} else {
|
||||
$this->info(trans('admin::app.promotion.cannot-activate-catalog-rule'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,10 @@ use Illuminate\Routing\Router;
|
|||
|
||||
class DiscountServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected $commands = [
|
||||
'Webkul\Discount\Commands\Console\ActivateCatalogRule'
|
||||
];
|
||||
|
||||
/**
|
||||
* Bootstrap services.
|
||||
*
|
||||
|
|
@ -25,6 +29,8 @@ class DiscountServiceProvider extends ServiceProvider
|
|||
public function register()
|
||||
{
|
||||
$this->registerConfig();
|
||||
|
||||
$this->commands($this->commands);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'enter-attribute' => 'Enter :attribute'
|
||||
'enter-attribute' => 'Enter :attribute',
|
||||
'select-attribute' => 'Select :attribute'
|
||||
];
|
||||
Loading…
Reference in New Issue