removed other changes

This commit is contained in:
Akhtar Khan 2020-08-19 15:35:51 +05:30
parent 7a03309de5
commit 9bfd5f3033
6 changed files with 48 additions and 180 deletions

View File

@ -2,16 +2,11 @@
namespace Webkul\Product\Models;
use Exception;
use Webkul\Product\Type\AbstractType;
use Illuminate\Database\Eloquent\Model;
use Webkul\Attribute\Models\AttributeFamilyProxy;
use Webkul\Category\Models\CategoryProxy;
use Webkul\Attribute\Models\AttributeProxy;
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;
class Product extends Model implements ProductContract
@ -64,8 +59,7 @@ class Product extends Model implements ProductContract
}
/**
* Get the product flat entries that are associated with product.
* May be one for each locale and each channel.
* Get the product variants that owns the product.
*/
public function product_flats()
{
@ -159,8 +153,7 @@ class Product extends Model implements ProductContract
*/
public function related_products()
{
$count = $this->getMetaData()->related_product_count;
return $this->belongsToMany(static::class, 'product_relations', 'parent_id', 'child_id')->limit($count);
return $this->belongsToMany(static::class, 'product_relations', 'parent_id', 'child_id')->limit(4);
}
/**
@ -168,8 +161,7 @@ class Product extends Model implements ProductContract
*/
public function up_sells()
{
$count = $this->getMetaData()->up_selling_product_count;
return $this->belongsToMany(static::class, 'product_up_sells', 'parent_id', 'child_id')->limit($count);
return $this->belongsToMany(static::class, 'product_up_sells', 'parent_id', 'child_id')->limit(4);
}
/**
@ -177,23 +169,7 @@ class Product extends Model implements ProductContract
*/
public function cross_sells()
{
$count = $this->getMetaData()->cross_selling_product_count;
return $this->belongsToMany(static::class, 'product_cross_sells', 'parent_id', 'child_id')->limit($count);
}
/**
* GetMetaData belongs to the Velocity Meta Data
*/
public function getMetaData()
{
$locale = app()->getLocale();
$channel = core()->getCurrentChannelCode();
$data = app(VelocityMetadataRepository::class)
->where('locale',$locale)
->where('channel',$channel)
->get();
return $data['0'];
return $this->belongsToMany(static::class, 'product_cross_sells', 'parent_id', 'child_id')->limit(4);
}
/**
@ -244,8 +220,8 @@ class Product extends Model implements ProductContract
public function inventory_source_qty($inventorySourceId)
{
return $this->inventories()
->where('inventory_source_id', $inventorySourceId)
->sum('qty');
->where('inventory_source_id', $inventorySourceId)
->sum('qty');
}
/**
@ -261,12 +237,6 @@ class Product extends Model implements ProductContract
$this->typeInstance = app(config('product_types.' . $this->type . '.class'));
if (! $this->typeInstance instanceof AbstractType) {
throw new Exception(
"Please ensure the product type '{$this->type}' is configured in your application."
);
}
$this->typeInstance->setProduct($this);
return $this->typeInstance;
@ -313,7 +283,6 @@ class Product extends Model implements ProductContract
*
* @param Group $group
* @param bool $skipSuperAttribute
*
* @return Collection
*/
public function getEditableAttributes($group = null, $skipSuperAttribute = true)
@ -324,8 +293,7 @@ class Product extends Model implements ProductContract
/**
* Get an attribute from the model.
*
* @param string $key
*
* @param string $key
* @return mixed
*/
public function getAttribute($key)
@ -337,8 +305,8 @@ class Product extends Model implements ProductContract
if (isset($this->id)) {
$this->attributes[$key] = '';
$attribute = core()->getSingletonInstance(AttributeRepository::class)
->getAttributeByCode($key);
$attribute = core()->getSingletonInstance(\Webkul\Attribute\Repositories\AttributeRepository::class)
->getAttributeByCode($key);
$this->attributes[$key] = $this->getCustomAttributeValue($attribute);
@ -359,9 +327,8 @@ class Product extends Model implements ProductContract
$hiddenAttributes = $this->getHidden();
if (isset($this->id)) {
$familyAttributes = core()
->getSingletonInstance(AttributeRepository::class)
->getFamilyAttributes($this->attribute_family);
$familyAttributes = core()->getSingletonInstance(\Webkul\Attribute\Repositories\AttributeRepository::class)
->getFamilyAttributes($this->attribute_family);
foreach ($familyAttributes as $attribute) {
if (in_array($attribute->code, $hiddenAttributes)) {
@ -410,13 +377,12 @@ class Product extends Model implements ProductContract
/**
* Overrides the default Eloquent query builder
*
* @param \Illuminate\Database\Eloquent\Builder $query
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public function newEloquentBuilder($query)
{
return new Builder($query);
return new \Webkul\Product\Database\Eloquent\Builder($query);
}
/**

View File

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

View File

@ -23,9 +23,6 @@ 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

@ -90,31 +90,27 @@ return [
]
],
'meta-data' => [
'footer' => 'Footer',
'title' => 'Velocity meta data',
'activate-slider' => 'Activate Slider',
'home-page-content' => 'Home Page Content',
'footer-left-content' => 'Footer Left Content',
'subscription-content' => 'Subscription bar Content',
'sidebar-categories' => 'Sidebar Categories',
'header_content_count' => 'Header Content 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',
'product-policy' => 'Product Policy',
'update-meta-data' => 'Update Meta Data',
'product-view-image' => 'Product View Image',
'advertisement-two' => 'Advertisement Two Images',
'advertisement-one' => 'Advertisement One Images',
'footer-middle-content' => 'Footer Middle Content',
'advertisement-four' => 'Advertisement Four Images',
'advertisement-three' => 'Advertisement Three Images',
'images' => 'Images',
'general' => 'General',
'add-image-btn-title' => 'Add Image'
'footer' => 'Footer',
'title' => 'Velocity meta data',
'activate-slider' => 'Activate Slider',
'home-page-content' => 'Home Page Content',
'footer-left-content' => 'Footer Left Content',
'subscription-content' => 'Subscription bar Content',
'sidebar-categories' => 'Sidebar Categories',
'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',
'product-policy' => 'Product Policy',
'update-meta-data' => 'Update Meta Data',
'product-view-image' => 'Product View Image',
'advertisement-two' => 'Advertisement Two Images',
'advertisement-one' => 'Advertisement One Images',
'footer-middle-content' => 'Footer Middle Content',
'advertisement-four' => 'Advertisement Four Images',
'advertisement-three' => 'Advertisement Three Images',
'images' => 'Images',
'general' => 'General',
'add-image-btn-title' => 'Add Image'
],
'category' => [
'save-btn-title' => 'Save Menu',
@ -198,11 +194,9 @@ return [
'compare' => [
'text' => 'Compare',
'compare_similar_items' => 'Compare Similar Items',
'add-tooltip' => 'Add product to compare list',
'added' => 'Item successfully added to compare list',
'already_added' => 'Item already added to compare list',
'removed' => 'Item successfully removed from compare list',
'removed-all' => 'All Items successfully removed from compare list',
'empty-text' => "You don't have any items in your compare list",
'product_image' => 'Product Image',
'actions' => 'Actions',
@ -270,12 +264,10 @@ return [
'orders' => 'Orders',
'update' => 'Update',
'reviews' => 'Reviews',
'download' => 'Download',
'currencies' => 'Currencies',
'addresses' => 'Addresses',
'top-brands' => 'Top Brands',
'new-password' => 'New password',
'no-file-available' => 'No File Available!',
'downloadables' => 'Downloadable Products',
'confirm-new-password' => 'Confirm new password',
'enter-current-password' => 'Enter your current password',

View File

@ -6,7 +6,6 @@
@php
$locale = request()->get('locale') ?: app()->getLocale();
$channel = request()->get('channel') ?: core()->getCurrentChannelCode();
@endphp
@section('content')
@ -30,25 +29,12 @@
</div>
<input type="hidden" name="locale" value="{{ $locale }}" />
<input type="hidden" name="channel" value="{{ $channel }}" />
<div class="control-group">
<select class="control" id="channel-switcher" onChange="window.location.href = this.value">
@foreach (core()->getAllChannels() as $ch)
<option value="{{ route('velocity.admin.meta-data') . '?channel=' . $ch->code . '&locale=' . $locale }}" {{ ($ch->code) == $channel ? 'selected' : '' }}>
{{ $ch->name }}
</option>
@endforeach
</select>
</div>
<div class="control-group">
<select class="control" id="locale-switcher" onChange="window.location.href = this.value">
@foreach (core()->getAllLocales() as $localeModel)
<option value="{{ route('velocity.admin.meta-data') . '?locale=' . $localeModel->code . '&channel=' . $channel }}" {{ ($localeModel->code) == $locale ? 'selected' : '' }}>
<option value="{{ route('velocity.admin.meta-data') . '?locale=' . $localeModel->code }}" {{ ($localeModel->code) == $locale ? 'selected' : '' }}>
{{ $localeModel->name }}
</option>
@ -76,7 +62,7 @@
class="control"
data-vv-as="&quot;slides&quot;"
{{ $metaData && $metaData->slider ? 'checked' : ''}} />
<span class="slider round"></span>
</label>
</div>
@ -92,17 +78,6 @@
value="{{ $metaData ? $metaData->sidebar_category_count : '10' }}" />
</div>
<div class="control-group">
<label>{{ __('velocity::app.admin.meta-data.header_content_count') }}</label>
<input
type="text"
class="control"
id="header_content_count"
name="header_content_count"
value="{{ $metaData ? $metaData->header_content_count : '5' }}" />
</div>
<div class="control-group">
<label>{{ __('shop::app.home.featured-products') }}</label>
@ -126,43 +101,7 @@
</div>
<div class="control-group">
<label>{{ __('velocity::app.admin.meta-data.up_selling_product_count') }}</label>
<input
type="text"
class="control"
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 : $channel }} - {{ $metaData ? $metaData->locale : $locale }}]</span>
</label>
<label>{{ __('velocity::app.admin.meta-data.home-page-content') }}</label>
<textarea
class="control"
@ -173,10 +112,7 @@
</div>
<div class="control-group">
<label style="width:100%;">
{{ __('velocity::app.admin.meta-data.product-policy') }}
<span class="locale">[{{ $metaData ? $metaData->channel : $channel }} - {{ $metaData ? $metaData->locale : $locale }}]</span>
</label>
<label>{{ __('velocity::app.admin.meta-data.product-policy') }}</label>
<textarea
class="control"
@ -200,13 +136,7 @@
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);
$advertisement = json_decode($metaData->get('advertisement')->all()[0]->advertisement, true);
@endphp
@if(! isset($advertisement[4]))
@ -289,10 +219,7 @@
<accordian :title="'{{ __('velocity::app.admin.meta-data.footer') }}'" :active="false">
<div slot="body">
<div class="control-group">
<label style="width:100%;">
{{ __('velocity::app.admin.meta-data.subscription-content') }}
<span class="locale">[{{ $metaData ? $metaData->channel : $channel }} - {{ $metaData ? $metaData->locale : $locale }}]</span>
</label>
<label>{{ __('velocity::app.admin.meta-data.subscription-content') }}</label>
<textarea
class="control"
@ -303,10 +230,7 @@
</div>
<div class="control-group">
<label style="width:100%;">
{{ __('velocity::app.admin.meta-data.footer-left-content') }}
<span class="locale">[{{ $metaData ? $metaData->channel : $channel }} - {{ $metaData ? $metaData->locale : $locale }}]</span>
</label>
<label>{{ __('velocity::app.admin.meta-data.footer-left-content') }}</label>
<textarea
class="control"
@ -317,10 +241,7 @@
</div>
<div class="control-group">
<label style="width:100%;">
{{ __('velocity::app.admin.meta-data.footer-middle-content') }}
<span class="locale">[{{ $metaData ? $metaData->channel : $channel }} - {{ $metaData ? $metaData->locale : $locale }}]</span>
</label>
<label>{{ __('velocity::app.admin.meta-data.footer-middle-content') }}</label>
<textarea
class="control"
@ -351,4 +272,4 @@
});
});
</script>
@endpush
@endpush

View File

@ -6,10 +6,6 @@
$products[] = $product;
$products = array_unique($products);
}
$data = app('Webkul\Product\Repositories\ProductRepository')
->getMetaData();
$product_count = $data->cross_selling_product_count;
?>
@endforeach
@ -27,10 +23,10 @@
navigation-enabled="hide"
pagination-enabled="hide"
id="upsell-products-carousel"
:slides-count="{{ $product->cross_sells()->count() }}">
:slides-count="{{ sizeof($products) }}">
@foreach($products as $product)
@foreach ($product->cross_sells()->paginate($product_count) as $index => $crossSellProduct)
@foreach ($product->cross_sells()->paginate(2) as $index => $crossSellProduct)
<slide slot="slide-{{ $index }}">
@include ('shop::products.list.card', [
'product' => $crossSellProduct,
@ -44,7 +40,7 @@
<div class="carousel-products vc-small-screen">
<carousel-component
:slides-count="{{ $product->cross_sells()->count() }}"
:slides-count="{{ sizeof($products) }}"
slides-per-page="2"
id="upsell-products-carousel"
navigation-enabled="hide"