Merge pull request #607 from rahulshukla-webkul/development

Development
This commit is contained in:
JItendra Singh 2019-02-20 17:19:23 +05:30 committed by GitHub
commit 4fb702bf5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 3 deletions

View File

@ -1,4 +1,4 @@
<select v-validate="'{{$validations}}'" class="control" id="{{ $attribute->code }}" name="{{ $attribute->code }}" data-vv-as="&quot;{{ $attribute->admin_name }}&quot;" multiple {{ $disabled ? 'disabled' : '' }}>
<select v-validate="'{{$validations}}'" class="control" id="{{ $attribute->code }}" name="{{ $attribute->code }}[]" data-vv-as="&quot;{{ $attribute->admin_name }}&quot;" multiple {{ $disabled ? 'disabled' : '' }}>
@foreach ($attribute->options as $option)
<option value="{{ $option->id }}" {{ in_array($option->id, explode(',', $attribute[$attribute->code])) ? 'selected' : ''}}>

View File

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

View File

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