Product Edit Page Handled

This commit is contained in:
devansh bawari 2021-06-08 11:41:21 +05:30
parent a8daf374e0
commit dace5f9ecb
3 changed files with 33 additions and 9 deletions

View File

@ -7,14 +7,13 @@
@section('content')
<div class="content">
@php
$locale = request()->get('locale') ?: app()->getLocale();
$channel = request()->get('channel') ?: core()->getDefaultChannelCode();
/* getting channel and locales */
$mainConfigurations = core()->getChannelCodeAndLocaleCode();
$channelLocales = app('Webkul\Core\Repositories\ChannelRepository')->findOneByField('code', $channel)->locales;
if (! $channelLocales->contains('code', $locale)) {
$locale = config('app.fallback_locale');
}
/* assigning */
$locale = $mainConfigurations['localeCode'];
$channel = $mainConfigurations['channelCode'];
$channelLocales = $mainConfigurations['channelLocales'];
@endphp
{!! view_render_event('bagisto.admin.catalog.product.edit.before', ['product' => $product]) !!}

View File

@ -282,6 +282,28 @@ class Core
return $locale;
}
/**
* Get channel code and locale code based on the request.
*
* @return array
*/
public function getChannelCodeAndLocaleCode()
{
$both = [
'channelCode' => request()->get('channel') ?: (core()->getCurrentChannelCode() ?: core()->getDefaultChannelCode()),
'localeCode' => request()->get('locale') ?: app()->getLocale()
];
$channel = $this->channelRepository->findOneByField('code', $both['channelCode']);
$both['channelLocales'] = $channel->locales;
if (! $both['channelLocales']->contains('code', $both['localeCode'])) {
$both['localeCode'] = $channel->default_locale->code;
}
return $both;
}
/**
* Returns all customer groups.
*

View File

@ -391,9 +391,12 @@ class Product extends Model implements ProductContract
return;
}
$channel = request()->get('channel') ?: (core()->getCurrentChannelCode() ?: core()->getDefaultChannelCode());
/* getting channel and locales */
$mainConfigurations = core()->getChannelCodeAndLocaleCode();
$locale = request()->get('locale') ?: app()->getLocale();
/* assigning */
$locale = $mainConfigurations['localeCode'];
$channel = $mainConfigurations['channelCode'];
if ($attribute->value_per_channel) {
if ($attribute->value_per_locale) {