This commit is contained in:
Akhtar Khan 2020-08-19 15:57:47 +05:30
parent 9bfd5f3033
commit 484728f5bc
4 changed files with 111 additions and 42 deletions

View File

@ -2,11 +2,15 @@
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\Product\Contracts\Product as ProductContract;
class Product extends Model implements ProductContract
@ -59,7 +63,8 @@ class Product extends Model implements ProductContract
}
/**
* Get the product variants that owns the product.
* Get the product flat entries that are associated with product.
* May be one for each locale and each channel.
*/
public function product_flats()
{
@ -220,8 +225,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');
}
/**
@ -237,6 +242,12 @@ 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;
@ -283,6 +294,7 @@ class Product extends Model implements ProductContract
*
* @param Group $group
* @param bool $skipSuperAttribute
*
* @return Collection
*/
public function getEditableAttributes($group = null, $skipSuperAttribute = true)
@ -293,7 +305,8 @@ class Product extends Model implements ProductContract
/**
* Get an attribute from the model.
*
* @param string $key
* @param string $key
*
* @return mixed
*/
public function getAttribute($key)
@ -305,8 +318,8 @@ class Product extends Model implements ProductContract
if (isset($this->id)) {
$this->attributes[$key] = '';
$attribute = core()->getSingletonInstance(\Webkul\Attribute\Repositories\AttributeRepository::class)
->getAttributeByCode($key);
$attribute = core()->getSingletonInstance(AttributeRepository::class)
->getAttributeByCode($key);
$this->attributes[$key] = $this->getCustomAttributeValue($attribute);
@ -327,8 +340,9 @@ class Product extends Model implements ProductContract
$hiddenAttributes = $this->getHidden();
if (isset($this->id)) {
$familyAttributes = core()->getSingletonInstance(\Webkul\Attribute\Repositories\AttributeRepository::class)
->getFamilyAttributes($this->attribute_family);
$familyAttributes = core()
->getSingletonInstance(AttributeRepository::class)
->getFamilyAttributes($this->attribute_family);
foreach ($familyAttributes as $attribute) {
if (in_array($attribute->code, $hiddenAttributes)) {
@ -377,12 +391,13 @@ 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 \Webkul\Product\Database\Eloquent\Builder($query);
return new Builder($query);
}
/**

View File

@ -90,27 +90,28 @@ 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',
'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',
'header_content_count' => 'Header Content 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'
],
'category' => [
'save-btn-title' => 'Save Menu',
@ -194,9 +195,11 @@ 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',
@ -264,10 +267,12 @@ 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,6 +6,7 @@
@php
$locale = request()->get('locale') ?: app()->getLocale();
$channel = request()->get('channel') ?: core()->getCurrentChannelCode();
@endphp
@section('content')
@ -29,12 +30,25 @@
</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 }}" {{ ($localeModel->code) == $locale ? 'selected' : '' }}>
<option value="{{ route('velocity.admin.meta-data') . '?locale=' . $localeModel->code . '&channel=' . $channel }}" {{ ($localeModel->code) == $locale ? 'selected' : '' }}>
{{ $localeModel->name }}
</option>
@ -62,7 +76,7 @@
class="control"
data-vv-as="&quot;slides&quot;"
{{ $metaData && $metaData->slider ? 'checked' : ''}} />
<span class="slider round"></span>
</label>
</div>
@ -78,6 +92,17 @@
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>
@ -101,7 +126,10 @@
</div>
<div class="control-group">
<label>{{ __('velocity::app.admin.meta-data.home-page-content') }}</label>
<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>
<textarea
class="control"
@ -112,7 +140,10 @@
</div>
<div class="control-group">
<label>{{ __('velocity::app.admin.meta-data.product-policy') }}</label>
<label style="width:100%;">
{{ __('velocity::app.admin.meta-data.product-policy') }}
<span class="locale">[{{ $metaData ? $metaData->channel : $channel }} - {{ $metaData ? $metaData->locale : $locale }}]</span>
</label>
<textarea
class="control"
@ -136,7 +167,16 @@
3 => [],
2 => [],
];
$advertisement = json_decode($metaData->get('advertisement')->all()[0]->advertisement, true);
$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
@if(! isset($advertisement[4]))
@ -219,7 +259,10 @@
<accordian :title="'{{ __('velocity::app.admin.meta-data.footer') }}'" :active="false">
<div slot="body">
<div class="control-group">
<label>{{ __('velocity::app.admin.meta-data.subscription-content') }}</label>
<label style="width:100%;">
{{ __('velocity::app.admin.meta-data.subscription-content') }}
<span class="locale">[{{ $metaData ? $metaData->channel : $channel }} - {{ $metaData ? $metaData->locale : $locale }}]</span>
</label>
<textarea
class="control"
@ -230,7 +273,10 @@
</div>
<div class="control-group">
<label>{{ __('velocity::app.admin.meta-data.footer-left-content') }}</label>
<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>
<textarea
class="control"
@ -241,7 +287,10 @@
</div>
<div class="control-group">
<label>{{ __('velocity::app.admin.meta-data.footer-middle-content') }}</label>
<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>
<textarea
class="control"

View File

@ -23,7 +23,7 @@
navigation-enabled="hide"
pagination-enabled="hide"
id="upsell-products-carousel"
:slides-count="{{ sizeof($products) }}">
:slides-count="{{ $product->cross_sells()->count() }}">
@foreach($products as $product)
@foreach ($product->cross_sells()->paginate(2) as $index => $crossSellProduct)
@ -40,7 +40,7 @@
<div class="carousel-products vc-small-screen">
<carousel-component
:slides-count="{{ sizeof($products) }}"
:slides-count="{{ $product->cross_sells()->count() }}"
slides-per-page="2"
id="upsell-products-carousel"
navigation-enabled="hide"