This commit is contained in:
parent
34b0613d48
commit
8377c8dc8f
|
|
@ -51,7 +51,7 @@ class ProductDataGrid extends DataGrid
|
|||
->select(
|
||||
'product_flat.locale',
|
||||
'product_flat.channel',
|
||||
'product_flat.product_id as product_id',
|
||||
'product_flat.product_id',
|
||||
'products.sku as product_sku',
|
||||
'product_flat.name as product_name',
|
||||
'products.type as product_type',
|
||||
|
|
@ -61,17 +61,9 @@ class ProductDataGrid extends DataGrid
|
|||
DB::raw('SUM(DISTINCT ' . DB::getTablePrefix() . 'product_inventories.qty) as quantity')
|
||||
);
|
||||
|
||||
if ($this->locale !== 'all') {
|
||||
$queryBuilder->where('product_flat.locale', $this->locale);
|
||||
}
|
||||
|
||||
if ($this->channel !== 'all') {
|
||||
$queryBuilder->where('product_flat.channel', $this->channel);
|
||||
}
|
||||
|
||||
$queryBuilder->groupBy('product_flat.product_id');
|
||||
$queryBuilder->having('locale', $this->locale !== 'all' ? $this->locale : 'en');
|
||||
$queryBuilder->having('channel', $this->channel !== 'all' ? $this->channel : 'default');
|
||||
$queryBuilder->groupBy('product_flat.product_id', 'product_flat.locale', 'product_flat.channel');
|
||||
$queryBuilder->where('locale', $this->locale !== 'all' ? $this->locale : 'en');
|
||||
$queryBuilder->where('channel', $this->channel !== 'all' ? $this->channel : 'default');
|
||||
|
||||
$this->addFilter('product_id', 'product_flat.product_id');
|
||||
$this->addFilter('product_name', 'product_flat.name');
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
@php
|
||||
$attributeRepository = app('\Webkul\Attribute\Repositories\AttributeRepository');
|
||||
$comparableAttributes = $attributeRepository->findByField('is_comparable', 1);
|
||||
|
||||
$locale = request()->get('locale') ?: app()->getLocale();
|
||||
|
||||
$attributeOptionTranslations = DB::table(DB::getTablePrefix() . 'attribute_option_translations')->where('locale', $locale)->get()->toJson();
|
||||
@endphp
|
||||
|
||||
@push('css')
|
||||
|
|
@ -116,7 +120,17 @@
|
|||
<span v-text="product.product['{{ $attribute['code'] }}'].substr(product.product['{{ $attribute['code'] }}'].lastIndexOf('/') + 1)" class="fs16"></span>
|
||||
<i class='material-icons'>arrow_downward</i>
|
||||
</a>
|
||||
<a v-else class="fs16">__</span>
|
||||
<span v-else class="fs16">__</span>
|
||||
@break;
|
||||
|
||||
@case('checkbox')
|
||||
<span v-if="product.product['{{ $attribute['code'] }}']" v-html="getAttributeOptions(product['{{ $attribute['code'] }}'] ? product : product.product['{{ $attribute['code'] }}'] ? product.product : null, '{{ $attribute['code'] }}', 'multiple')" class="fs16"></span>
|
||||
<span v-else class="fs16">__</span>
|
||||
@break;
|
||||
|
||||
@case('select')
|
||||
<span v-if="product.product['{{ $attribute['code'] }}']" v-html="getAttributeOptions(product['{{ $attribute['code'] }}'] ? product : product.product['{{ $attribute['code'] }}'] ? product.product : null, '{{ $attribute['code'] }}', 'single')" class="fs16"></span>
|
||||
<span v-else class="fs16">__</span>
|
||||
@break;
|
||||
@default
|
||||
<span v-html="product['{{ $attribute['code'] }}'] ? product['{{ $attribute['code'] }}'] : product.product['{{ $attribute['code'] }}'] ? product.product['{{ $attribute['code'] }}'] : '__'" class="fs16"></span>
|
||||
|
|
@ -148,6 +162,7 @@
|
|||
return {
|
||||
'products': [],
|
||||
'isProductListLoaded': false,
|
||||
'attributeOptions': JSON.parse(@json($attributeOptionTranslations)),
|
||||
'isCustomer': '{{ auth()->guard('customer')->user() ? "true" : "false" }}' == "true",
|
||||
}
|
||||
},
|
||||
|
|
@ -238,6 +253,42 @@
|
|||
|
||||
this.$root.headerItemsCount++;
|
||||
},
|
||||
|
||||
'getAttributeOptions': function (productDetails, attributeValues, type) {
|
||||
var attributeOptions = '__';
|
||||
|
||||
if (productDetails && attributeValues) {
|
||||
var attributeItems;
|
||||
|
||||
if (type == "multiple") {
|
||||
attributeItems = productDetails[attributeValues].split(',');
|
||||
} else if (type == "single") {
|
||||
attributeItems = productDetails[attributeValues];
|
||||
}
|
||||
|
||||
attributeOptions = this.attributeOptions.filter(option => {
|
||||
if (type == "multiple") {
|
||||
if (attributeItems.indexOf(option.attribute_option_id.toString()) > -1) {
|
||||
return true;
|
||||
}
|
||||
} else if (type == "single") {
|
||||
if (attributeItems == option.attribute_option_id.toString()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
attributeOptions = attributeOptions.map(option => {
|
||||
return option.label;
|
||||
});
|
||||
|
||||
attributeOptions = attributeOptions.join(', ');
|
||||
}
|
||||
|
||||
return attributeOptions;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue