Merge pull request #1227 from rahulshukla-webkul/development
product creation on channel based and admin logo
This commit is contained in:
commit
a38711df1a
|
|
@ -52,11 +52,11 @@ class LocalesDataGrid extends DataGrid
|
|||
'sortable' => true,
|
||||
'filterable' => true
|
||||
]);
|
||||
|
||||
|
||||
$this->addColumn([
|
||||
'index' => 'direction',
|
||||
'label' => trans('admin::app.datagrid.direction'),
|
||||
'type' => 'select',
|
||||
'type' => 'string',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'filterable' => true
|
||||
|
|
|
|||
|
|
@ -396,7 +396,8 @@ return [
|
|||
'related-products' => 'Related Products',
|
||||
'product-search-hint' => 'Start typing product name',
|
||||
'no-result-found' => 'Products not found with same name.',
|
||||
'searching' => 'Searching ...'
|
||||
'searching' => 'Searching ...',
|
||||
'channel' => 'Channels'
|
||||
],
|
||||
|
||||
'attributes' => [
|
||||
|
|
@ -448,7 +449,7 @@ return [
|
|||
'image' => 'Image',
|
||||
'file' => 'File',
|
||||
'checkbox' => 'Checkbox',
|
||||
'use_in_flat' => "Create in Product Flat Table"
|
||||
'use_in_flat' => "Create in Product Flat Table",
|
||||
],
|
||||
'families' => [
|
||||
'title' => 'Families',
|
||||
|
|
@ -492,6 +493,8 @@ return [
|
|||
'meta_description' => 'Meta Description',
|
||||
'meta_keywords' => 'Meta Keywords',
|
||||
'image' => 'Image',
|
||||
'filterable-attributes' => 'Filterable Attributes',
|
||||
'attributes' => 'Attributes',
|
||||
]
|
||||
],
|
||||
|
||||
|
|
|
|||
|
|
@ -136,6 +136,23 @@
|
|||
|
||||
@endif
|
||||
|
||||
<accordian :title="'{{ __('admin::app.catalog.categories.filterable-attributes') }}'" :active="true">
|
||||
<div slot="body">
|
||||
<div class="control-group" :class="[errors.has('attributes[]') ? 'has-error' : '']">
|
||||
<label for="attributes" class="required">{{ __('admin::app.catalog.categories.attributes') }}</label>
|
||||
<select class="control" name="attributes[]" v-validate="'required'" data-vv-as=""{{ __('admin::app.catalog.categories.attributes') }}"" multiple>
|
||||
@foreach ($attributes as $attribute)
|
||||
<option value="{{ $attribute->id }}">
|
||||
{{ $attribute->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<span class="control-error" v-if="errors.has('attributes[]')">
|
||||
@{{ errors.first('attributes[]') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</accordian>
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.create_form_accordian.seo.before') !!}
|
||||
|
||||
|
|
|
|||
|
|
@ -148,6 +148,23 @@
|
|||
|
||||
@endif
|
||||
|
||||
<accordian :title="'{{ __('admin::app.catalog.categories.filterable-attributes') }}'" :active="true">
|
||||
<div slot="body">
|
||||
<div class="control-group" :class="[errors.has('attributes[]') ? 'has-error' : '']">
|
||||
<label for="attributes" class="required">{{ __('admin::app.catalog.categories.attributes') }}</label>
|
||||
<select class="control" name="attributes[]" v-validate="'required'" data-vv-as=""{{ __('admin::app.catalog.categories.attributes') }}"" multiple>
|
||||
@foreach ($attributes as $attribute)
|
||||
<option value="{{ $attribute->id }}" {{ in_array($attribute->id, $category->filterableAttributes->pluck('id')->toArray()) ? 'selected' : ''}}>
|
||||
{{ $attribute->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<span class="control-error" v-if="errors.has('attributes[]')">
|
||||
@{{ errors.first('attributes[]') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</accordian>
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.edit_form_accordian.seo.before', ['category' => $category]) !!}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
<accordian :title="'{{ __('admin::app.catalog.products.channel') }}'" :active="true">
|
||||
<div slot="body">
|
||||
<div class="control-group" :class="[errors.has('channels[]') ? 'has-error' : '']">
|
||||
<label for="channels" class="required">{{ __('admin::app.catalog.products.channel') }}</label>
|
||||
<select class="control" name="channels[]" v-validate="'required'" data-vv-as=""{{ __('admin::app.catalog.products.channel') }}"" multiple>
|
||||
@foreach (app('Webkul\Core\Repositories\ChannelRepository')->all() as $channel)
|
||||
<option value="{{ $channel->id }}">
|
||||
{{ $channel->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
|
||||
<span class="control-error" v-if="errors.has('channels[]')">
|
||||
@{{ errors.first('channels[]') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</accordian>
|
||||
|
|
@ -150,6 +150,7 @@
|
|||
|
||||
@endforeach
|
||||
|
||||
@include ('admin::catalog.products.accordians.channels')
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.product.edit_form_accordian.inventories.before', ['product' => $product]) !!}
|
||||
|
||||
|
|
|
|||
|
|
@ -438,16 +438,16 @@
|
|||
this_this.isRequire = true;
|
||||
}
|
||||
|
||||
var dependentElement = document.getElementById(this_this.depand);
|
||||
var depandValue = this_this.value;
|
||||
|
||||
if (depandValue == 'true') {
|
||||
depandValue = 1;
|
||||
} else if (depandValue == 'false') {
|
||||
depandValue = 0;
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
var dependentElement = document.getElementById(this_this.depand);
|
||||
var depandValue = this_this.value;
|
||||
|
||||
if (depandValue == 'true') {
|
||||
depandValue = 1;
|
||||
} else if (depandValue == 'false') {
|
||||
depandValue = 0;
|
||||
}
|
||||
|
||||
$(document).on("change", "select.control", function() {
|
||||
if (this_this.depand == this.name) {
|
||||
if (this_this.value == this.value) {
|
||||
|
|
@ -457,17 +457,21 @@
|
|||
}
|
||||
}
|
||||
})
|
||||
|
||||
if (dependentElement && dependentElement.value == depandValue) {
|
||||
this_this.isVisible = true;
|
||||
} else {
|
||||
this_this.isVisible = false;
|
||||
}
|
||||
|
||||
if (this_this.result) {
|
||||
if (dependentElement.value == this_this.value) {
|
||||
this_this.isVisible = true;
|
||||
} else {
|
||||
this_this.isVisible = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (dependentElement && dependentElement.value == depandValue) {
|
||||
this_this.isVisible = true;
|
||||
} else {
|
||||
this_this.isVisible = false;
|
||||
}
|
||||
|
||||
if (this_this.result) {
|
||||
this_this.isVisible = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
@php
|
||||
$locale = Webkul\Core\Models\Locale::where('code', app()->getLocale())->first();
|
||||
@endphp
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ config('app.locale') }}">
|
||||
<head>
|
||||
|
|
@ -71,7 +67,7 @@
|
|||
|
||||
{!! view_render_event('bagisto.admin.layout.head') !!}
|
||||
</head>
|
||||
<body @if ($locale->direction == 'rtl') class="rtl" @endif style="scroll-behavior: smooth;">
|
||||
<body @if (core()->getCurrentLocale()->direction == 'rtl') class="rtl" @endif style="scroll-behavior: smooth;">
|
||||
<div id="app" class="container">
|
||||
|
||||
<flash-wrapper ref='flashes'></flash-wrapper>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
@php
|
||||
$locale = Webkul\Core\Models\Locale::where('code', app()->getLocale())->first();
|
||||
@endphp
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ config('app.locale') }}">
|
||||
<head>
|
||||
|
|
@ -23,7 +19,7 @@
|
|||
|
||||
</head>
|
||||
|
||||
<body @if ($locale->direction == 'rtl') class="rtl" @endif style="scroll-behavior: smooth;">
|
||||
<body @if (core()->getCurrentLocale()->direction == 'rtl') class="rtl" @endif style="scroll-behavior: smooth;">
|
||||
{!! view_render_event('bagisto.admin.layout.body.before') !!}
|
||||
|
||||
<div id="app">
|
||||
|
|
|
|||
|
|
@ -2,7 +2,11 @@
|
|||
<div class="navbar-top-left">
|
||||
<div class="brand-logo">
|
||||
<a href="{{ route('admin.dashboard.index') }}">
|
||||
<img src="{{ asset('vendor/webkul/ui/assets/images/logo.png') }}" alt="Bagisto"/>
|
||||
@if (core()->getConfigData('general.design.admin_logo.logo_image'))
|
||||
<img src="{{ \Illuminate\Support\Facades\Storage::url(core()->getConfigData('general.design.admin_logo.logo_image')) }}" alt="Bagisto" style="height: 40px; width: 110px;"/>
|
||||
@else
|
||||
<img src="{{ asset('vendor/webkul/ui/assets/images/logo.png') }}" alt="Bagisto"/>
|
||||
@endif
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateCategoryFilterableAttributesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('category_filterable_attributes', function (Blueprint $table) {
|
||||
$table->integer('category_id')->unsigned();
|
||||
$table->integer('attribute_id')->unsigned();
|
||||
$table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
|
||||
$table->foreign('attribute_id')->references('id')->on('attributes')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('category_filterable_attributes');
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ namespace Webkul\Category\Http\Controllers;
|
|||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Category\Repositories\CategoryRepository as Category;
|
||||
use Webkul\Attribute\Repositories\AttributeRepository as Attribute;
|
||||
use Webkul\Category\Models\CategoryTranslation;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
|
|
@ -30,16 +31,26 @@ class CategoryController extends Controller
|
|||
*/
|
||||
protected $category;
|
||||
|
||||
/**
|
||||
* AttributeRepository object
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $attribute;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Category\Repositories\CategoryRepository $category
|
||||
* @param \Webkul\Category\Repositories\CategoryRepository $category
|
||||
* @param use Webkul\Attribute\Repositories\AttributeRepository $attribute
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Category $category)
|
||||
public function __construct(Category $category, Attribute $attribute)
|
||||
{
|
||||
$this->category = $category;
|
||||
|
||||
$this->attribute = $attribute;
|
||||
|
||||
$this->_config = request('_config');
|
||||
}
|
||||
|
||||
|
|
@ -62,7 +73,9 @@ class CategoryController extends Controller
|
|||
{
|
||||
$categories = $this->category->getCategoryTree(null, ['id']);
|
||||
|
||||
return view($this->_config['view'], compact('categories'));
|
||||
$attributes = $this->attribute->findWhere(['is_filterable' => 1]);
|
||||
|
||||
return view($this->_config['view'], compact('categories', 'attributes'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -110,7 +123,9 @@ class CategoryController extends Controller
|
|||
|
||||
$category = $this->category->findOrFail($id);
|
||||
|
||||
return view($this->_config['view'], compact('category', 'categories'));
|
||||
$attributes = $this->attribute->findWhere(['is_filterable' => 1]);
|
||||
|
||||
return view($this->_config['view'], compact('category', 'categories', 'attributes'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use Webkul\Core\Eloquent\TranslatableModel;
|
|||
use Kalnoy\Nestedset\NodeTrait;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Webkul\Category\Contracts\Category as CategoryContract;
|
||||
use Webkul\Attribute\Models\AttributeProxy;
|
||||
|
||||
class Category extends TranslatableModel implements CategoryContract
|
||||
{
|
||||
|
|
@ -35,4 +36,12 @@ class Category extends TranslatableModel implements CategoryContract
|
|||
{
|
||||
return $this->image_url();
|
||||
}
|
||||
|
||||
/**
|
||||
* The filterable attributes that belong to the category.
|
||||
*/
|
||||
public function filterableAttributes()
|
||||
{
|
||||
return $this->belongsToMany(AttributeProxy::modelClass(), 'category_filterable_attributes')->with('options');
|
||||
}
|
||||
}
|
||||
|
|
@ -63,6 +63,10 @@ class CategoryRepository extends Repository
|
|||
|
||||
$this->uploadImages($data, $category);
|
||||
|
||||
if (isset($data['attributes'])) {
|
||||
$category->filterableAttributes()->sync($data['attributes']);
|
||||
}
|
||||
|
||||
Event::fire('catalog.category.create.after', $category);
|
||||
|
||||
return $category;
|
||||
|
|
@ -163,6 +167,10 @@ class CategoryRepository extends Repository
|
|||
|
||||
$this->uploadImages($data, $category);
|
||||
|
||||
if (isset($data['attributes'])) {
|
||||
$category->filterableAttributes()->sync($data['attributes']);
|
||||
}
|
||||
|
||||
Event::fire('catalog.category.update.after', $id);
|
||||
|
||||
return $category;
|
||||
|
|
|
|||
|
|
@ -936,27 +936,35 @@ class Cart {
|
|||
'country' => $shippingAddress->country,
|
||||
])->orderBy('tax_rate', 'desc')->get();
|
||||
|
||||
foreach ($taxRates as $rate) {
|
||||
$haveTaxRate = false;
|
||||
if (count( $taxRates) > 0) {
|
||||
foreach ($taxRates as $rate) {
|
||||
$haveTaxRate = false;
|
||||
|
||||
if (! $rate->is_zip) {
|
||||
if ($rate->zip_code == '*' || $rate->zip_code == $shippingAddress->postcode) {
|
||||
$haveTaxRate = true;
|
||||
if (! $rate->is_zip) {
|
||||
if ($rate->zip_code == '*' || $rate->zip_code == $shippingAddress->postcode) {
|
||||
$haveTaxRate = true;
|
||||
}
|
||||
} else {
|
||||
if ($shippingAddress->postcode >= $rate->zip_from && $shippingAddress->postcode <= $rate->zip_to) {
|
||||
$haveTaxRate = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($shippingAddress->postcode >= $rate->zip_from && $shippingAddress->postcode <= $rate->zip_to) {
|
||||
$haveTaxRate = true;
|
||||
|
||||
if ($haveTaxRate) {
|
||||
$item->tax_percent = $rate->tax_rate;
|
||||
$item->tax_amount = ($item->total * $rate->tax_rate) / 100;
|
||||
$item->base_tax_amount = ($item->base_total * $rate->tax_rate) / 100;
|
||||
|
||||
$item->save();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$item->tax_percent = 0;
|
||||
$item->tax_amount = 0;
|
||||
$item->base_tax_amount = 0;
|
||||
|
||||
if ($haveTaxRate) {
|
||||
$item->tax_percent = $rate->tax_rate;
|
||||
$item->tax_amount = ($item->total * $rate->tax_rate) / 100;
|
||||
$item->base_tax_amount = ($item->base_total * $rate->tax_rate) / 100;
|
||||
|
||||
$item->save();
|
||||
break;
|
||||
}
|
||||
$item->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,25 +52,31 @@ class ForgotPasswordController extends Controller
|
|||
*/
|
||||
public function store()
|
||||
{
|
||||
$this->validate(request(), [
|
||||
'email' => 'required|email'
|
||||
]);
|
||||
try {
|
||||
$this->validate(request(), [
|
||||
'email' => 'required|email'
|
||||
]);
|
||||
|
||||
$response = $this->broker()->sendResetLink(
|
||||
request(['email'])
|
||||
);
|
||||
//dd($response);
|
||||
if ($response == Password::RESET_LINK_SENT) {
|
||||
session()->flash('success', trans($response));
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
return back()
|
||||
->withInput(request(['email']))
|
||||
->withErrors(
|
||||
['email' => trans($response)]
|
||||
$response = $this->broker()->sendResetLink(
|
||||
request(['email'])
|
||||
);
|
||||
|
||||
if ($response == Password::RESET_LINK_SENT) {
|
||||
session()->flash('success', trans($response));
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
return back()
|
||||
->withInput(request(['email']))
|
||||
->withErrors(
|
||||
['email' => trans($response)]
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
session()->flash('error', trans($e->getMessage()));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class RedirectIfNotCustomer
|
|||
public function handle($request, Closure $next, $guard = 'customer')
|
||||
{
|
||||
if (! Auth::guard($guard)->check()) {
|
||||
return redirect()->route('customer.profile.index');
|
||||
return redirect()->route('customer.session.index');
|
||||
} else {
|
||||
if (Auth::guard($guard)->user()->status == 0) {
|
||||
Auth::guard($guard)->logout();
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ class ProductFlat
|
|||
public function afterAttributeCreatedUpdated($attribute)
|
||||
{
|
||||
if (! $attribute->is_user_defined || ! $attribute->use_in_flat) {
|
||||
$this->afterAttributeDeleted($attribute->id);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -169,100 +170,125 @@ class ProductFlat
|
|||
if ($parentProduct && ! array_key_exists($parentProduct->id, $superAttributes))
|
||||
$superAttributes[$parentProduct->id] = $parentProduct->super_attributes()->pluck('code')->toArray();
|
||||
|
||||
foreach (core()->getAllChannels() as $channel) {
|
||||
foreach ($channel->locales as $locale) {
|
||||
$productFlat = $this->productFlatRepository->findOneWhere([
|
||||
'product_id' => $product->id,
|
||||
'channel' => $channel->code,
|
||||
'locale' => $locale->code
|
||||
]);
|
||||
if (isset($product['channels'])) {
|
||||
foreach ($product['channels'] as $channel) {
|
||||
$channel = app('Webkul\Core\Repositories\ChannelRepository')->findOrFail($channel);
|
||||
$channels[] = $channel['code'];
|
||||
}
|
||||
} else if (isset($parentProduct['channels'])){
|
||||
foreach ($parentProduct['channels'] as $channel) {
|
||||
$channel = app('Webkul\Core\Repositories\ChannelRepository')->findOrFail($channel);
|
||||
$channels[] = $channel['code'];
|
||||
}
|
||||
} else {
|
||||
$channels[] = core()->getDefaultChannelCode();
|
||||
}
|
||||
|
||||
if (! $productFlat) {
|
||||
$productFlat = $this->productFlatRepository->create([
|
||||
foreach (core()->getAllChannels() as $channel) {
|
||||
if (in_array($channel->code, $channels)) {
|
||||
foreach ($channel->locales as $locale) {
|
||||
$productFlat = $this->productFlatRepository->findOneWhere([
|
||||
'product_id' => $product->id,
|
||||
'channel' => $channel->code,
|
||||
'locale' => $locale->code
|
||||
]);
|
||||
}
|
||||
|
||||
foreach ($familyAttributes[$product->attribute_family->id] as $attribute) {
|
||||
if ($parentProduct && ! in_array($attribute->code, array_merge($superAttributes[$parentProduct->id], ['sku', 'name', 'price', 'weight', 'status'])))
|
||||
continue;
|
||||
|
||||
if (in_array($attribute->code, ['tax_category_id']))
|
||||
continue;
|
||||
|
||||
if (! Schema::hasColumn('product_flat', $attribute->code))
|
||||
continue;
|
||||
|
||||
if ($attribute->value_per_channel) {
|
||||
if ($attribute->value_per_locale) {
|
||||
$productAttributeValue = $product->attribute_values()->where('channel', $channel->code)->where('locale', $locale->code)->where('attribute_id', $attribute->id)->first();
|
||||
} else {
|
||||
$productAttributeValue = $product->attribute_values()->where('channel', $channel->code)->where('attribute_id', $attribute->id)->first();
|
||||
}
|
||||
} else {
|
||||
if ($attribute->value_per_locale) {
|
||||
$productAttributeValue = $product->attribute_values()->where('locale', $locale->code)->where('attribute_id', $attribute->id)->first();
|
||||
} else {
|
||||
$productAttributeValue = $product->attribute_values()->where('attribute_id', $attribute->id)->first();
|
||||
}
|
||||
}
|
||||
|
||||
if ($product->type == 'configurable' && $attribute->code == 'price') {
|
||||
$productFlat->{$attribute->code} = app('Webkul\Product\Helpers\Price')->getVariantMinPrice($product);
|
||||
} else {
|
||||
$productFlat->{$attribute->code} = $productAttributeValue[ProductAttributeValue::$attributeTypeFields[$attribute->type]];
|
||||
}
|
||||
|
||||
if ($attribute->type == 'select') {
|
||||
$attributeOption = $this->attributeOptionRepository->find($product->{$attribute->code});
|
||||
|
||||
if ($attributeOption) {
|
||||
if ($attributeOptionTranslation = $attributeOption->translate($locale->code)) {
|
||||
$productFlat->{$attribute->code . '_label'} = $attributeOptionTranslation->label;
|
||||
} else {
|
||||
$productFlat->{$attribute->code . '_label'} = $attributeOption->admin_name;
|
||||
}
|
||||
}
|
||||
} elseif ($attribute->type == 'multiselect') {
|
||||
$attributeOptionIds = explode(',', $product->{$attribute->code});
|
||||
|
||||
if (count($attributeOptionIds)) {
|
||||
$attributeOptions = $this->attributeOptionRepository->findWhereIn('id', $attributeOptionIds);
|
||||
|
||||
$optionLabels = [];
|
||||
|
||||
foreach ($attributeOptions as $attributeOption) {
|
||||
if ($attributeOptionTranslation = $attributeOption->translate($locale->code)) {
|
||||
$optionLabels[] = $attributeOptionTranslation->label;
|
||||
} else {
|
||||
$optionLabels[] = $attributeOption->admin_name;
|
||||
}
|
||||
}
|
||||
|
||||
$productFlat->{$attribute->code . '_label'} = implode(', ', $optionLabels);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$productFlat->created_at = $product->created_at;
|
||||
|
||||
$productFlat->updated_at = $product->updated_at;
|
||||
|
||||
if ($parentProduct) {
|
||||
$parentProductFlat = $this->productFlatRepository->findOneWhere([
|
||||
'product_id' => $parentProduct->id,
|
||||
if (! $productFlat) {
|
||||
$productFlat = $this->productFlatRepository->create([
|
||||
'product_id' => $product->id,
|
||||
'channel' => $channel->code,
|
||||
'locale' => $locale->code
|
||||
]);
|
||||
|
||||
if ($parentProductFlat) {
|
||||
$productFlat->parent_id = $parentProductFlat->id;
|
||||
}
|
||||
}
|
||||
|
||||
$productFlat->save();
|
||||
foreach ($familyAttributes[$product->attribute_family->id] as $attribute) {
|
||||
if ($parentProduct && ! in_array($attribute->code, array_merge($superAttributes[$parentProduct->id], ['sku', 'name', 'price', 'weight', 'status'])))
|
||||
continue;
|
||||
|
||||
if (in_array($attribute->code, ['tax_category_id']))
|
||||
continue;
|
||||
|
||||
if (! Schema::hasColumn('product_flat', $attribute->code))
|
||||
continue;
|
||||
|
||||
if ($attribute->value_per_channel) {
|
||||
if ($attribute->value_per_locale) {
|
||||
$productAttributeValue = $product->attribute_values()->where('channel', $channel->code)->where('locale', $locale->code)->where('attribute_id', $attribute->id)->first();
|
||||
} else {
|
||||
$productAttributeValue = $product->attribute_values()->where('channel', $channel->code)->where('attribute_id', $attribute->id)->first();
|
||||
}
|
||||
} else {
|
||||
if ($attribute->value_per_locale) {
|
||||
$productAttributeValue = $product->attribute_values()->where('locale', $locale->code)->where('attribute_id', $attribute->id)->first();
|
||||
} else {
|
||||
$productAttributeValue = $product->attribute_values()->where('attribute_id', $attribute->id)->first();
|
||||
}
|
||||
}
|
||||
|
||||
if ($product->type == 'configurable' && $attribute->code == 'price') {
|
||||
$productFlat->{$attribute->code} = app('Webkul\Product\Helpers\Price')->getVariantMinPrice($product);
|
||||
} else {
|
||||
$productFlat->{$attribute->code} = $productAttributeValue[ProductAttributeValue::$attributeTypeFields[$attribute->type]];
|
||||
}
|
||||
|
||||
if ($attribute->type == 'select') {
|
||||
$attributeOption = $this->attributeOptionRepository->find($product->{$attribute->code});
|
||||
|
||||
if ($attributeOption) {
|
||||
if ($attributeOptionTranslation = $attributeOption->translate($locale->code)) {
|
||||
$productFlat->{$attribute->code . '_label'} = $attributeOptionTranslation->label;
|
||||
} else {
|
||||
$productFlat->{$attribute->code . '_label'} = $attributeOption->admin_name;
|
||||
}
|
||||
}
|
||||
} elseif ($attribute->type == 'multiselect') {
|
||||
$attributeOptionIds = explode(',', $product->{$attribute->code});
|
||||
|
||||
if (count($attributeOptionIds)) {
|
||||
$attributeOptions = $this->attributeOptionRepository->findWhereIn('id', $attributeOptionIds);
|
||||
|
||||
$optionLabels = [];
|
||||
|
||||
foreach ($attributeOptions as $attributeOption) {
|
||||
if ($attributeOptionTranslation = $attributeOption->translate($locale->code)) {
|
||||
$optionLabels[] = $attributeOptionTranslation->label;
|
||||
} else {
|
||||
$optionLabels[] = $attributeOption->admin_name;
|
||||
}
|
||||
}
|
||||
|
||||
$productFlat->{$attribute->code . '_label'} = implode(', ', $optionLabels);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$productFlat->created_at = $product->created_at;
|
||||
|
||||
$productFlat->updated_at = $product->updated_at;
|
||||
|
||||
if ($parentProduct) {
|
||||
$parentProductFlat = $this->productFlatRepository->findOneWhere([
|
||||
'product_id' => $parentProduct->id,
|
||||
'channel' => $channel->code,
|
||||
'locale' => $locale->code
|
||||
]);
|
||||
|
||||
if ($parentProductFlat) {
|
||||
$productFlat->parent_id = $parentProductFlat->id;
|
||||
}
|
||||
}
|
||||
|
||||
$productFlat->save();
|
||||
}
|
||||
} else {
|
||||
$productFlat = $this->productFlatRepository->findOneWhere([
|
||||
'product_id' => $product->id,
|
||||
'channel' => $channel->code,
|
||||
]);
|
||||
|
||||
if ($productFlat) {
|
||||
$this->productFlatRepository->delete($productFlat->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -260,6 +260,10 @@ class ProductRepository extends Repository
|
|||
$this->productImage->uploadImages($data, $product);
|
||||
}
|
||||
|
||||
if (isset($data['channels'])) {
|
||||
$product['channels'] = $data['channels'];
|
||||
}
|
||||
|
||||
Event::fire('catalog.product.update.after', $product);
|
||||
|
||||
return $product;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class OrderDataGrid extends DataGrid
|
|||
public function prepareQueryBuilder()
|
||||
{
|
||||
$queryBuilder = DB::table('orders as order')
|
||||
->addSelect('order.id', 'order.status', 'order.created_at', 'order.grand_total')
|
||||
->addSelect('order.id', 'order.status', 'order.created_at', 'order.grand_total', 'order.order_currency_code')
|
||||
->where('customer_id', auth()->guard('customer')->user()->id);
|
||||
|
||||
$this->setQueryBuilder($queryBuilder);
|
||||
|
|
@ -49,10 +49,13 @@ class OrderDataGrid extends DataGrid
|
|||
$this->addColumn([
|
||||
'index' => 'grand_total',
|
||||
'label' => trans('shop::app.customer.account.order.index.total'),
|
||||
'type' => 'price',
|
||||
'type' => 'number',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'filterable' => true
|
||||
'filterable' => true,
|
||||
'wrapper' => function ($value) {
|
||||
return core()->formatPrice($value->grand_total, $value->order_currency_code);
|
||||
}
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
@php
|
||||
$locale = Webkul\Core\Models\Locale::where('code', app()->getLocale())->first();
|
||||
@endphp
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ app()->getLocale() }}">
|
||||
|
||||
|
|
@ -34,7 +30,8 @@
|
|||
|
||||
</head>
|
||||
|
||||
<body @if ($locale->direction == 'rtl') class="rtl" @endif style="scroll-behavior: smooth;">
|
||||
|
||||
<body @if (core()->getCurrentLocale()->direction == 'rtl') class="rtl" @endif style="scroll-behavior: smooth;">
|
||||
|
||||
{!! view_render_event('bagisto.shop.layout.body.before') !!}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,24 +2,26 @@
|
|||
|
||||
@inject ('productFlatRepository', 'Webkul\Product\Repositories\ProductFlatRepository')
|
||||
|
||||
@inject ('productAttributeValueRepository', 'Webkul\Product\Repositories\ProductAttributeValueRepository')
|
||||
|
||||
<?php
|
||||
$filterAttributes = [];
|
||||
|
||||
if (isset($category)) {
|
||||
$categoryProductAttributes = $productFlatRepository->getCategoryProductAttribute($category->id);
|
||||
if (count($category->filterableAttributes) > 0) {
|
||||
$filterAttributes = $category->filterableAttributes;
|
||||
} else {
|
||||
$categoryProductAttributes = $productFlatRepository->getCategoryProductAttribute($category->id);
|
||||
|
||||
if ($categoryProductAttributes) {
|
||||
foreach ($attributeRepository->getFilterAttributes() as $filterAttribute) {
|
||||
if (in_array($filterAttribute->id, $categoryProductAttributes)) {
|
||||
$filterAttributes[] = $filterAttribute;
|
||||
} else if ($filterAttribute ['code'] == 'price') {
|
||||
$filterAttributes[] = $filterAttribute;
|
||||
if ($categoryProductAttributes) {
|
||||
foreach ($attributeRepository->getFilterAttributes() as $filterAttribute) {
|
||||
if (in_array($filterAttribute->id, $categoryProductAttributes)) {
|
||||
$filterAttributes[] = $filterAttribute;
|
||||
} else if ($filterAttribute ['code'] == 'price') {
|
||||
$filterAttributes[] = $filterAttribute;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$filterAttributes = collect($filterAttributes);
|
||||
$filterAttributes = collect($filterAttributes);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$filterAttributes = $attributeRepository->getFilterAttributes();
|
||||
|
|
|
|||
Loading…
Reference in New Issue