Merge pull request #607 from rahulshukla-webkul/development
Development
This commit is contained in:
commit
4fb702bf5d
|
|
@ -1,4 +1,4 @@
|
|||
<select v-validate="'{{$validations}}'" class="control" id="{{ $attribute->code }}" name="{{ $attribute->code }}" data-vv-as=""{{ $attribute->admin_name }}"" multiple {{ $disabled ? 'disabled' : '' }}>
|
||||
<select v-validate="'{{$validations}}'" class="control" id="{{ $attribute->code }}" name="{{ $attribute->code }}[]" data-vv-as=""{{ $attribute->admin_name }}"" multiple {{ $disabled ? 'disabled' : '' }}>
|
||||
|
||||
@foreach ($attribute->options as $option)
|
||||
<option value="{{ $option->id }}" {{ in_array($option->id, explode(',', $attribute[$attribute->code])) ? 'selected' : ''}}>
|
||||
|
|
|
|||
|
|
@ -19,10 +19,25 @@ class View extends AbstractProduct
|
|||
$attributeOptionReposotory = app('Webkul\Attribute\Repositories\AttributeOptionRepository');
|
||||
|
||||
foreach ($attributes as $attribute) {
|
||||
if ($attribute->is_visible_on_front && $product->{$attribute->code}) {
|
||||
if ($attribute->type == 'boolean') {
|
||||
$value = $product->{$attribute->code};
|
||||
if ($attribute->is_visible_on_front ) {
|
||||
if ($value == 1) {
|
||||
$value = 'Yes';
|
||||
} else {
|
||||
$value = 'No';
|
||||
}
|
||||
|
||||
$data[] = [
|
||||
'code' => $attribute->code,
|
||||
'label' => $attribute->name,
|
||||
'value' => $value,
|
||||
];
|
||||
}
|
||||
} else if ($attribute->is_visible_on_front && $product->{$attribute->code}) {
|
||||
$value = $product->{$attribute->code};
|
||||
|
||||
if (($attribute->type == 'select') || ($attribute->type == 'multiselect')) {
|
||||
if ($attribute->type == 'select') {
|
||||
$attributeOption = $attributeOptionReposotory->find($value);
|
||||
|
||||
if ($attributeOption) {
|
||||
|
|
@ -30,6 +45,22 @@ class View extends AbstractProduct
|
|||
}
|
||||
}
|
||||
|
||||
if ($attribute->type == 'multiselect') {
|
||||
$values = explode(",", $value);
|
||||
|
||||
$result = [];
|
||||
foreach ($values as $value) {
|
||||
$attributeOption = $attributeOptionReposotory->find($value);
|
||||
|
||||
if ($attributeOption) {
|
||||
$value = $attributeOption->translate(app()->getLocale())->label;
|
||||
$result[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$value = implode(",", $result);
|
||||
}
|
||||
|
||||
$data[] = [
|
||||
'code' => $attribute->code,
|
||||
'label' => $attribute->name,
|
||||
|
|
|
|||
|
|
@ -162,6 +162,10 @@ class ProductRepository extends Repository
|
|||
if (! isset($data[$attribute->code]) || (in_array($attribute->type, ['date', 'datetime']) && ! $data[$attribute->code]))
|
||||
continue;
|
||||
|
||||
if ($attribute->type == 'multiselect') {
|
||||
$data[$attribute->code] = implode(",", $data[$attribute->code]);
|
||||
}
|
||||
|
||||
$attributeValue = $this->attributeValue->findOneWhere([
|
||||
'product_id' => $product->id,
|
||||
'attribute_id' => $attribute->id,
|
||||
|
|
|
|||
Loading…
Reference in New Issue