This commit is contained in:
Akhtar Khan 2020-08-18 18:02:01 +05:30
parent 896c30e8c8
commit 0e563fcc20
8 changed files with 69 additions and 28 deletions

View File

@ -11,8 +11,8 @@ use Webkul\Product\Database\Eloquent\Builder;
use Webkul\Attribute\Models\AttributeFamilyProxy;
use Webkul\Inventory\Models\InventorySourceProxy;
use Webkul\Attribute\Repositories\AttributeRepository;
use Webkul\Velocity\Repositories\VelocityMetadataRepository;
use Webkul\Product\Contracts\Product as ProductContract;
use DB;
class Product extends Model implements ProductContract
{
@ -159,7 +159,8 @@ class Product extends Model implements ProductContract
*/
public function related_products()
{
return $this->belongsToMany(static::class, 'product_relations', 'parent_id', 'child_id')->limit(4);
$count = $this->getMetaData()->related_product_count;
return $this->belongsToMany(static::class, 'product_relations', 'parent_id', 'child_id')->limit($count);
}
/**
@ -167,9 +168,8 @@ class Product extends Model implements ProductContract
*/
public function up_sells()
{
$data = DB::table('velocity_meta_data')
->select('bundle_product_count')->get();
return $this->belongsToMany(static::class, 'product_up_sells', 'parent_id', 'child_id')->limit($data['0']->bundle_product_count);
$count = $this->getMetaData()->up_selling_product_count;
return $this->belongsToMany(static::class, 'product_up_sells', 'parent_id', 'child_id')->limit($count);
}
/**
@ -177,7 +177,20 @@ class Product extends Model implements ProductContract
*/
public function cross_sells()
{
return $this->belongsToMany(static::class, 'product_cross_sells', 'parent_id', 'child_id')->limit(4);
$count = $this->getMetaData()->cross_selling_product_count;
return $this->belongsToMany(static::class, 'product_cross_sells', 'parent_id', 'child_id')->limit($count);
}
public function getMetaData()
{
$locale = app()->getLocale();
$channel = core()->getCurrentChannelCode();
$data = app(VelocityMetadataRepository::class)
->where('locale',$locale)
->where('channel',$channel)
->get();
return $data['0'];
}
/**

View File

@ -6,6 +6,10 @@
$products[] = $product;
$products = array_unique($products);
}
$data = app('Webkul\Product\Repositories\ProductRepository')
->getMetaData();
$product_count = $data->cross_selling_product_count;
?>
@endforeach
@ -21,7 +25,7 @@
<div class="product-grid-4">
@foreach($products as $product)
@foreach ($product->cross_sells()->paginate(2) as $cross_sell_product)
@foreach ($product->cross_sells()->paginate($product_count) as $cross_sell_product)
@include ('shop::products.list.card', ['product' => $cross_sell_product])

View File

@ -23,6 +23,9 @@ class CreateVelocityMetaData extends Migration
$table->integer('sidebar_category_count')->default(9);
$table->integer('featured_product_count')->default(10);
$table->integer('new_products_count')->default(10);
$table->integer('up_selling_product_count')->default(10);
$table->integer('cross_selling_product_count')->default(5);
$table->integer('related_product_count')->default(10);
$table->text('subscription_bar_content')->nullable();
$table->timestamps();
});

View File

@ -15,7 +15,6 @@ class UpdateVelocityMetaData extends Migration
{
Schema::table('velocity_meta_data', function (Blueprint $table) {
$table->json('product_view_images')->nullable();
$table->integer('bundle_product_count')->nullable();
});
}
@ -28,7 +27,6 @@ class UpdateVelocityMetaData extends Migration
{
Schema::table('velocity_meta_data', function (Blueprint $table) {
$table->dropColumn('product_view_images');
$table->dropColumn('bundle_product_count');
});
}
}

View File

@ -21,7 +21,6 @@ class VelocityMetaDataSeeder extends Seeder
'home_page_content' => "<p>@include('shop::home.advertisements.advertisement-four')@include('shop::home.featured-products') @include('shop::home.product-policy') @include('shop::home.advertisements.advertisement-three') @include('shop::home.new-products') @include('shop::home.advertisements.advertisement-two')</p>",
'header_content_count' => "5",
'bundle_product_count' => "10",
'footer_left_content' => __('velocity::app.admin.meta-data.footer-left-raw-content'),
'footer_middle_content' => '<div class="col-lg-6 col-md-12 col-sm-12 no-padding"><ul type="none"><li><a href="https://webkul.com/about-us/company-profile/">About Us</a></li><li><a href="https://webkul.com/about-us/company-profile/">Customer Service</a></li><li><a href="https://webkul.com/about-us/company-profile/">What&rsquo;s New</a></li><li><a href="https://webkul.com/about-us/company-profile/">Contact Us </a></li></ul></div><div class="col-lg-6 col-md-12 col-sm-12 no-padding"><ul type="none"><li><a href="https://webkul.com/about-us/company-profile/"> Order and Returns </a></li><li><a href="https://webkul.com/about-us/company-profile/"> Payment Policy </a></li><li><a href="https://webkul.com/about-us/company-profile/"> Shipping Policy</a></li><li><a href="https://webkul.com/about-us/company-profile/"> Privacy and Cookies Policy </a></li></ul></div>',

View File

@ -98,7 +98,9 @@ return [
'subscription-content' => 'Subscription bar Content',
'sidebar-categories' => 'Sidebar Categories',
'header_content_count' => 'Header Content Count',
'bundle_product_count' => 'Bundle Product Count',
'up_selling_product_count' => 'Up Selling Product Count',
'cross_selling_product_count'=>'Cross Selling Product Count',
'related_product_count' => 'Related Product Count',
'footer-left-raw-content' => '<p>We love to craft softwares and solve the real world problems with the binaries. We are highly committed to our goals. We invest our resources to create world class easy to use softwares and applications for the enterprise business with the top notch, on the edge technology expertise.</p>',
'slider-path' => 'Slider Path',
'category-logo' => 'Category logo',

View File

@ -5,8 +5,8 @@
@stop
@php
$locale = request()->get('locale') ?: 'en';
$channel = request()->get('channel') ?: 'default';
$locale = request()->get('locale') ?: app()->getLocale();
$channel = request()->get('channel') ?: core()->getCurrentChannelCode();
@endphp
@section('content')
@ -125,22 +125,43 @@
value="{{ $metaData ? $metaData->new_products_count : 10 }}" />
</div>
<div class="control-group">
<label>{{ __('velocity::app.admin.meta-data.bundle_product_count') }}</label>
<label>{{ __('velocity::app.admin.meta-data.up_selling_product_count') }}</label>
<input
type="text"
class="control"
id="bundle_product_count"
name="bundle_product_count"
value="{{$metaData->bundle_product_count}}" />
id="up_selling_product_count"
name="up_selling_product_count"
value="{{$metaData->up_selling_product_count}}" />
</div>
<div class="control-group">
<label>{{ __('velocity::app.admin.meta-data.cross_selling_product_count') }}</label>
<input
type="text"
class="control"
id="cross_selling_product_count"
name="cross_selling_product_count"
value="{{$metaData->cross_selling_product_count}}" />
</div>
<div class="control-group">
<label>{{ __('velocity::app.admin.meta-data.related_product_count') }}</label>
<input
type="text"
class="control"
id="related_product_count"
name="related_product_count"
value="{{$metaData->related_product_count}}" />
</div>
<div class="control-group">
<label style="width:100%;">
{{ __('velocity::app.admin.meta-data.home-page-content') }}
<span class="locale">[{{ $metaData ? $metaData->channel : 'default' }} - {{ $metaData ? $metaData->locale : 'en' }}]</span>
<span class="locale">[{{ $metaData ? $metaData->channel : $channel }} - {{ $metaData ? $metaData->locale : $locale }}]</span>
</label>
<textarea
@ -154,7 +175,7 @@
<div class="control-group">
<label style="width:100%;">
{{ __('velocity::app.admin.meta-data.product-policy') }}
<span class="locale">[{{ $metaData ? $metaData->channel : 'default' }} - {{ $metaData ? $metaData->locale : 'en' }}]</span>
<span class="locale">[{{ $metaData ? $metaData->channel : $channel }} - {{ $metaData ? $metaData->locale : $locale }}]</span>
</label>
<textarea
@ -179,15 +200,12 @@
3 => [],
2 => [],
];
$index = 0;
foreach ($metaData->get('locale')->all() as $key => $value) {
if ($value->locale == $locale) {
$index = $key;
}
}
$advertisement = json_decode($metaData->get('advertisement')->all()[$index]->advertisement, true);
@endphp
@ -273,7 +291,7 @@
<div class="control-group">
<label style="width:100%;">
{{ __('velocity::app.admin.meta-data.subscription-content') }}
<span class="locale">[{{ $metaData ? $metaData->channel : 'default' }} - {{ $metaData ? $metaData->locale : 'en' }}]</span>
<span class="locale">[{{ $metaData ? $metaData->channel : $channel }} - {{ $metaData ? $metaData->locale : $locale }}]</span>
</label>
<textarea
@ -287,7 +305,7 @@
<div class="control-group">
<label style="width:100%;">
{{ __('velocity::app.admin.meta-data.footer-left-content') }}
<span class="locale">[{{ $metaData ? $metaData->channel : 'default' }} - {{ $metaData ? $metaData->locale : 'en' }}]</span>
<span class="locale">[{{ $metaData ? $metaData->channel : $channel }} - {{ $metaData ? $metaData->locale : $locale }}]</span>
</label>
<textarea
@ -301,7 +319,7 @@
<div class="control-group">
<label style="width:100%;">
{{ __('velocity::app.admin.meta-data.footer-middle-content') }}
<span class="locale">[{{ $metaData ? $metaData->channel : 'default' }} - {{ $metaData ? $metaData->locale : 'en' }}]</span>
<span class="locale">[{{ $metaData ? $metaData->channel : $channel }} - {{ $metaData ? $metaData->locale : $locale }}]</span>
</label>
<textarea
@ -333,4 +351,4 @@
});
});
</script>
@endpush
@endpush

View File

@ -6,6 +6,10 @@
$products[] = $product;
$products = array_unique($products);
}
$data = app('Webkul\Product\Repositories\ProductRepository')
->getMetaData();
$product_count = $data->cross_selling_product_count;
?>
@endforeach
@ -26,7 +30,7 @@
:slides-count="{{ $product->cross_sells()->count() }}">
@foreach($products as $product)
@foreach ($product->cross_sells()->paginate(2) as $index => $crossSellProduct)
@foreach ($product->cross_sells()->paginate($product_count) as $index => $crossSellProduct)
<slide slot="slide-{{ $index }}">
@include ('shop::products.list.card', [
'product' => $crossSellProduct,