product linking completed
This commit is contained in:
parent
3bb197c75a
commit
281567456b
|
|
@ -228,11 +228,11 @@ Route::group(['middleware' => ['web']], function () {
|
|||
'redirect' => 'admin.catalog.products.index'
|
||||
])->name('admin.catalog.products.massupdate');
|
||||
|
||||
//product search for linked products
|
||||
Route::get('products/search', 'Webkul\Product\Http\Controllers\ProductController@productLinkSearch')->defaults('_config', [
|
||||
'view' => 'admin::catalog.products.edit'
|
||||
])->name('admin.catalog.products.productlinksearch');
|
||||
|
||||
|
||||
// Catalog Category Routes
|
||||
Route::get('/categories', 'Webkul\Category\Http\Controllers\CategoryController@index')->defaults('_config', [
|
||||
'view' => 'admin::catalog.categories.index'
|
||||
|
|
|
|||
|
|
@ -382,8 +382,7 @@ return [
|
|||
'related-products' => 'Related Products',
|
||||
'product-search-hint' => 'Start typing product name',
|
||||
'no-result-found' => 'Products not found with same name.',
|
||||
'searching' => 'Searching ...',
|
||||
'related-products' => ':name'
|
||||
'searching' => 'Searching ...'
|
||||
],
|
||||
|
||||
'attributes' => [
|
||||
|
|
|
|||
|
|
@ -6,17 +6,20 @@
|
|||
</div>
|
||||
</accordian>
|
||||
|
||||
|
||||
@push('scripts')
|
||||
|
||||
<script type="text/x-template" id="linked-products-template">
|
||||
<div>
|
||||
|
||||
<div class="control-group" v-for='(key) in linkedProducts'>
|
||||
<label for="up-selling">
|
||||
{{
|
||||
__('admin::app.catalog.products.related-products', ['name' => 'cross_selling'])
|
||||
}}
|
||||
<label for="up-selling" v-if="(key == 'up_sells')">
|
||||
{{ __('admin::app.catalog.products.up-selling') }}
|
||||
</label>
|
||||
<label for="cross_sells" v-if="(key == 'cross_sells')">
|
||||
{{ __('admin::app.catalog.products.cross-selling') }}
|
||||
</label>
|
||||
<label for="related_products" v-if="(key == 'related_products')">
|
||||
{{ __('admin::app.catalog.products.related-products') }}
|
||||
</label>
|
||||
|
||||
<input type="text" class="control" autocomplete="off" v-model="search_term[key]" placeholder="{{ __('admin::app.catalog.products.product-search-hint') }}" v-on:keyup="search(key)">
|
||||
|
|
@ -49,7 +52,6 @@
|
|||
<span class="icon cross-icon" @click="removeProduct(product, key)"></span>
|
||||
</span>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
@ -86,6 +88,8 @@
|
|||
'related_products': false
|
||||
},
|
||||
|
||||
productId: {{ $product->id }},
|
||||
|
||||
linkedProducts: ['up_sells', 'cross_sells', 'related_products'],
|
||||
|
||||
upSellingProducts: @json($product->up_sells()->get()),
|
||||
|
|
@ -138,6 +142,13 @@
|
|||
if (this.search_term[key].length >= 1) {
|
||||
this.$http.get ("{{ route('admin.catalog.products.productlinksearch') }}", {params: {query: this.search_term[key]}})
|
||||
.then (function(response) {
|
||||
|
||||
for (var index in response.data) {
|
||||
if (response.data[index].id == this_this.productId) {
|
||||
response.data.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
this_this.products[key] = response.data;
|
||||
|
||||
this_this.is_searching[key] = false;
|
||||
|
|
|
|||
|
|
@ -196,14 +196,23 @@ class ProductRepository extends Repository
|
|||
|
||||
if (isset($data['up_sell'])) {
|
||||
$product->up_sells()->sync($data['up_sell']);
|
||||
} else {
|
||||
$data['up_sell'] = [];
|
||||
$product->up_sells()->sync($data['up_sell']);
|
||||
}
|
||||
|
||||
if (isset($data['cross_sell'])) {
|
||||
$product->cross_sells()->sync($data['cross_sell']);
|
||||
} else {
|
||||
$data['cross_sell'] = [];
|
||||
$product->cross_sells()->sync($data['cross_sell']);
|
||||
}
|
||||
|
||||
if (isset($data['related_products'])) {
|
||||
$product->related_products()->sync($data['related_products']);
|
||||
} else {
|
||||
$data['related_products'] = [];
|
||||
$product->related_products()->sync($data['related_products']);
|
||||
}
|
||||
|
||||
$previousVariantIds = $product->variants->pluck('id');
|
||||
|
|
|
|||
|
|
@ -6,18 +6,17 @@
|
|||
|
||||
@if ($products)
|
||||
|
||||
<div class="attached-products-wrapper mt-50">
|
||||
@foreach ($products as $product)
|
||||
|
||||
<div class="title">
|
||||
{{ __('shop::app.products.cross-sell-title') }}
|
||||
<span class="border-bottom"></span>
|
||||
</div>
|
||||
@if ($product->cross_sells()->count())
|
||||
<div class="attached-products-wrapper mt-50">
|
||||
|
||||
<div class="product-grid-4">
|
||||
<div class="title">
|
||||
{{ __('shop::app.products.cross-sell-title') }}
|
||||
<span class="border-bottom"></span>
|
||||
</div>
|
||||
|
||||
@foreach ($products as $product)
|
||||
|
||||
@if ($product->cross_sells()->count())
|
||||
<div class="product-grid-4">
|
||||
|
||||
@foreach ($product->cross_sells()->paginate(1) as $cross_sell_product)
|
||||
|
||||
|
|
@ -25,13 +24,13 @@
|
|||
|
||||
@endforeach
|
||||
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
@endif
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue