Issue #834 fixed

This commit is contained in:
jitendra 2019-04-18 12:52:51 +05:30
parent 7fc68c56ae
commit e99daf28e2
20 changed files with 152 additions and 172 deletions

View File

@ -1,5 +1,4 @@
<?php
return [
'modules' => [
/**
@ -8,7 +7,6 @@ return [
* VendorB\ModuleY\Providers\ModuleServiceProvider::class
*
*/
\Webkul\Attribute\Providers\ModuleServiceProvider::class,
\Webkul\Category\Providers\ModuleServiceProvider::class,
\Webkul\Checkout\Providers\ModuleServiceProvider::class,

View File

@ -16,7 +16,7 @@ return [
'enabled' => env('DEBUGBAR_ENABLED', null),
'except' => [
'telescope*'
//
],
/*
@ -143,7 +143,7 @@ return [
'timeline' => false, // Add the queries to the timeline
'explain' => [ // Show EXPLAIN output on queries
'enabled' => false,
'types' => ['SELECT'], // // workaround ['SELECT'] only. https://github.com/barryvdh/laravel-debugbar/issues/888 ['SELECT', 'INSERT', 'UPDATE', 'DELETE']; for MySQL 5.6.3+
'types' => ['SELECT'], // ['SELECT', 'INSERT', 'UPDATE', 'DELETE']; for MySQL 5.6.3+
],
'hints' => true, // Show hints for common mistakes
],

View File

@ -3,7 +3,6 @@
use Maatwebsite\Excel\Excel;
return [
'exports' => [
/*
@ -17,6 +16,17 @@ return [
*/
'chunk_size' => 1000,
/*
|--------------------------------------------------------------------------
| Temporary path
|--------------------------------------------------------------------------
|
| When exporting files, we use a temporary file, before storing
| or downloading. Here you can customize that path.
|
*/
'temp_path' => sys_get_temp_dir(),
/*
|--------------------------------------------------------------------------
| Pre-calculate formulas during export
@ -59,23 +69,6 @@ return [
*/
'formatter' => 'slug',
],
/*
|--------------------------------------------------------------------------
| CSV Settings
|--------------------------------------------------------------------------
|
| Configure e.g. delimiter, enclosure and line ending for CSV imports.
|
*/
'csv' => [
'delimiter' => ',',
'enclosure' => '"',
'line_ending' => PHP_EOL,
'use_bom' => false,
'include_separator_line' => false,
'excel_compatibility' => false,
],
],
/*
@ -116,71 +109,4 @@ return [
*/
'pdf' => Excel::DOMPDF,
],
'value_binder' => [
/*
|--------------------------------------------------------------------------
| Default Value Binder
|--------------------------------------------------------------------------
|
| PhpSpreadsheet offers a way to hook into the process of a value being
| written to a cell. In there some assumptions are made on how the
| value should be formatted. If you want to change those defaults,
| you can implement your own default value binder.
|
*/
'default' => Maatwebsite\Excel\DefaultValueBinder::class,
],
'transactions' => [
/*
|--------------------------------------------------------------------------
| Transaction Handler
|--------------------------------------------------------------------------
|
| By default the import is wrapped in a transaction. This is useful
| for when an import may fail and you want to retry it. With the
| transactions, the previous import gets rolled-back.
|
| You can disable the transaction handler by setting this to null.
| Or you can choose a custom made transaction handler here.
|
| Supported handlers: null|db
|
*/
'handler' => 'db',
],
'temporary_files' => [
/*
|--------------------------------------------------------------------------
| Local Temporary Path
|--------------------------------------------------------------------------
|
| When exporting and importing files, we use a temporary file, before
| storing reading or downloading. Here you can customize that path.
|
*/
'local_path' => sys_get_temp_dir(),
/*
|--------------------------------------------------------------------------
| Remote Temporary Disk
|--------------------------------------------------------------------------
|
| When dealing with a multi server setup with queues in which you
| cannot rely on having a shared local temporary path, you might
| want to store the temporary file on a shared disk. During the
| queue executing, we'll retrieve the temporary file from that
| location instead. When left to null, it will always use
| the local path. This setting only has effect when using
| in conjunction with queued imports and exports.
|
*/
'remote_disk' => null,
],
];

View File

@ -2,21 +2,6 @@
return [
/*
|--------------------------------------------------------------------------
| Console Commands
|--------------------------------------------------------------------------
|
| This option allows you to add additional Artisan commands that should
| be available within the Tinker environment. Once the command is in
| this array you may execute the command in Tinker using its name.
|
*/
'commands' => [
// App\Console\Commands\ExampleCommand::class,
],
/*
|--------------------------------------------------------------------------
| Alias Blacklist
@ -28,8 +13,6 @@ return [
|
*/
'dont_alias' => [
'App\Nova',
],
'dont_alias' => [],
];

View File

@ -39,8 +39,6 @@ return [
| As a default locale, Translatable takes the locale of Laravel's
| translator. If for some reason you want to override this,
| you can specify what default should be used here.
| If you set a value here it will only use the current config value
| and never fallback to the translator one.
|
*/
'locale' => null,
@ -82,18 +80,6 @@ return [
*/
'fallback_locale' => 'en',
/*
|--------------------------------------------------------------------------
| Translation Model Namespace
|--------------------------------------------------------------------------
|
| Defines the default 'Translation' class namespace. For example, if
| you want to use App\Translations\CountryTranslation instead of App\CountryTranslation
| set this to 'App\Translations'.
|
*/
'translation_model_namespace' => null,
/*
|--------------------------------------------------------------------------
| Translation Suffix

View File

@ -15,20 +15,19 @@ return [
* of your proxy (e.g. if using ELB or similar).
*
*/
'proxies' => null, // [<ip addresses>,], '*', '<ip addresses>,'
'proxies' => null, // [<ip addresses>,], '*'
/*
* To trust one or more specific proxies that connect
* directly to your server, use an array or a string separated by comma of IP addresses:
* directly to your server, use an array of IP addresses:
*/
// 'proxies' => ['192.168.1.1'],
// 'proxies' => '192.168.1.1, 192.168.1.2',
# 'proxies' => ['192.168.1.1'],
/*
* Or, to trust all proxies that connect
* directly to your server, use a "*"
*/
// 'proxies' => '*',
# 'proxies' => '*',
/*
* Which headers to use to detect proxy related data (For, Host, Proto, Port)
@ -37,14 +36,10 @@ return [
*
* - Illuminate\Http\Request::HEADER_X_FORWARDED_ALL (use all x-forwarded-* headers to establish trust)
* - Illuminate\Http\Request::HEADER_FORWARDED (use the FORWARDED header to establish trust)
* - Illuminate\Http\Request::HEADER_X_FORWARDED_AWS_ELB (If you are using AWS Elastic Load Balancer)
*
* - 'HEADER_X_FORWARDED_ALL' (use all x-forwarded-* headers to establish trust)
* - 'HEADER_FORWARDED' (use the FORWARDED header to establish trust)
* - 'HEADER_X_FORWARDED_AWS_ELB' (If you are using AWS Elastic Load Balancer)
*
* @link https://symfony.com/doc/current/deployment/proxies.html
*/
'headers' => Illuminate\Http\Request::HEADER_X_FORWARDED_ALL,
];

View File

@ -183,7 +183,7 @@
];
});
var super_attributes = @json($product->super_attributes()->with('options')->get());
var super_attributes = @json(app('\Webkul\Product\Repositories\ProductRepository')->getSuperAttributes($product));
var variants = @json($product->variants);
Vue.component('variant-form', {

View File

@ -184,4 +184,30 @@ class AttributeRepository extends Repository
return $this->findWhereIn('code', $codes, $attributeColumns);
}
/**
* @return Object
*/
public function getAttributeByCode($code)
{
static $attributes = [];
if (array_key_exists($code, $attributes))
return $attributes[$code];
return $attributes[$code] = $this->findOneByField('code', $code);
}
/**
* @return Object
*/
public function getFamilyAttributes($attributeFamily)
{
static $attributes = [];
if (array_key_exists($attributeFamily->id, $attributes))
return $attributes[$attributeFamily->id];
return $attributes[$attributeFamily->id] = $attributeFamily->custom_attributes;
}
}

View File

@ -836,7 +836,8 @@ class Core
return $merged;
}
public function convertEmptyStringsToNull($array) {
public function convertEmptyStringsToNull($array)
{
foreach($array as $key => $value) {
if($value == "" || $value == "null") {
$array[$key] = null;
@ -845,4 +846,20 @@ class Core
return $array;
}
/**
* Create singletom object through single facade
*
* @param string $className
* @return object
*/
public function getSingletonInstance($className)
{
static $instance = [];
if (array_key_exists($className, $instance))
return $instance[$className];
return $instance[$className] = app($className);
}
}

View File

@ -45,7 +45,7 @@ class Channel extends Model implements ChannelContract
}
protected $with = ['base_currency'];
// protected $with = ['base_currency'];
/**
* Get the base currency

View File

@ -82,8 +82,10 @@ class ProductForm extends FormRequest
$attributes = $product->attribute_family->custom_attributes;
$productSuperAttributes = $product->super_attributes;
foreach ($attributes as $attribute) {
if (! $product->super_attributes->contains($attribute)) {
if (! $productSuperAttributes->contains($attribute)) {
if ($attribute->code == 'sku') {
continue;
}
@ -93,6 +95,7 @@ class ProductForm extends FormRequest
}
$validations = [];
if ($attribute->is_required) {
array_push($validations, 'required');
} else {
@ -111,7 +114,7 @@ class ProductForm extends FormRequest
array_push($validations, function ($field, $value, $fail) use ($inputs, $attribute) {
$column = ProductAttributeValue::$attributeTypeFields[$attribute->type];
if (!$this->attributeValue->isValueUnique($this->id, $attribute->id, $column, $inputs[$attribute->code])) {
if (! $this->attributeValue->isValueUnique($this->id, $attribute->id, $column, $inputs[$attribute->code])) {
$fail('The :attribute has already been taken.');
}
});

View File

@ -104,16 +104,14 @@ class ProductFlat
return false;
}
if (Schema::hasTable('product_flat')) {
if (!Schema::hasColumn('product_flat', $attribute->code)) {
Schema::table('product_flat', function (Blueprint $table) use($attribute) {
$table->{$this->attributeTypeFields[$attribute->type]}($attribute->code)->nullable();
if (! Schema::hasColumn('product_flat', $attribute->code)) {
Schema::table('product_flat', function (Blueprint $table) use($attribute) {
$table->{$this->attributeTypeFields[$attribute->type]}($attribute->code)->nullable();
if ($attribute->type == 'select' || $attribute->type == 'multiselect') {
$table->string($attribute->code . '_label')->nullable();
}
});
}
if ($attribute->type == 'select' || $attribute->type == 'multiselect') {
$table->string($attribute->code . '_label')->nullable();
}
});
}
}
@ -121,16 +119,14 @@ class ProductFlat
{
$attribute = $this->attributeRepository->find($attributeId);
if (Schema::hasTable('product_flat')) {
if (Schema::hasColumn('product_flat', strtolower($attribute->code))) {
Schema::table('product_flat', function (Blueprint $table) use($attribute) {
$table->dropColumn($attribute->code);
if (Schema::hasColumn('product_flat', strtolower($attribute->code))) {
Schema::table('product_flat', function (Blueprint $table) use($attribute) {
$table->dropColumn($attribute->code);
if ($attribute->type == 'select' || $attribute->type == 'multiselect') {
$table->dropColumn($attribute->code . '_label');
}
});
}
if ($attribute->type == 'select' || $attribute->type == 'multiselect') {
$table->dropColumn($attribute->code . '_label');
}
});
}
}
@ -160,6 +156,11 @@ class ProductFlat
*/
public function createFlat($product, $parentProduct = null)
{
static $familyAttributes = [];
if (! array_key_exists($product->attribute_family->id, $familyAttributes))
$familyAttributes[$product->attribute_family->id] = $product->attribute_family->custom_attributes;
foreach (core()->getAllChannels() as $channel) {
foreach ($channel->locales as $locale) {
$productFlat = $this->productFlatRepository->findOneWhere([
@ -168,7 +169,7 @@ class ProductFlat
'locale' => $locale->code
]);
if (!$productFlat) {
if (! $productFlat) {
$productFlat = $this->productFlatRepository->create([
'product_id' => $product->id,
'channel' => $channel->code,
@ -176,10 +177,16 @@ class ProductFlat
]);
}
foreach ($product->attribute_family->custom_attributes as $attribute) {
if (!Schema::hasTable('product_flat') || !Schema::hasColumn('product_flat', $attribute->code))
foreach ($familyAttributes[$product->attribute_family->id] as $attribute) {
if ($parentProduct && ! in_array($attribute->code, ['sku', 'name', 'price', 'weight', 'status']))
continue;
if (in_array($attribute->code, ['short_description', 'tax_category_id', 'meta_title', 'meta_keywords', 'meta_description', 'width', 'height']))
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();

View File

@ -210,7 +210,8 @@ class Product extends Model implements ProductContract
if (isset($this->id)) {
$this->attributes[$key] = '';
$attribute = app(\Webkul\Attribute\Repositories\AttributeRepository::class)->findOneByField('code', $key);
$attribute = core()->getSingletonInstance(\Webkul\Attribute\Repositories\AttributeRepository::class)
->getAttributeByCode($key);
$this->attributes[$key] = $this->getCustomAttributeValue($attribute);
@ -231,7 +232,10 @@ class Product extends Model implements ProductContract
$hiddenAttributes = $this->getHidden();
if (isset($this->id)) {
foreach ($this->attribute_family->custom_attributes as $attribute) {
$familyAttributes = core()->getSingletonInstance(\Webkul\Attribute\Repositories\AttributeRepository::class)
->getFamilyAttributes($this->attribute_family);
foreach ($familyAttributes as $attribute) {
if (in_array($attribute->code, $hiddenAttributes)) {
continue;
}
@ -290,7 +294,14 @@ class Product extends Model implements ProductContract
*/
public function getProductIdAttribute()
{
return $image = $this->id;
return $this->id;
}
/**
* Return the product attribute.
*/
public function getProductAttribute()
{
return $this;
}
}

View File

@ -11,7 +11,7 @@ class ProductAttributeValue extends Model implements ProductAttributeValueContra
{
public $timestamps = false;
protected $with = ['attribute'];
// protected $with = ['attribute'];
/**
* @var array

View File

@ -605,4 +605,30 @@ class ProductRepository extends Repository
return $results;
}
/**
* Returns product's super attribute with options
*
* @param Product $product
* @return Collection
*/
public function getSuperAttributes($product)
{
$superAttrbutes = [];
foreach ($product->super_attributes as $key => $attribute) {
$superAttrbutes[$key] = $attribute->toArray();
foreach ($attribute->options as $option) {
$superAttrbutes[$key]['options'][] = [
'id' => $option->id,
'admin_name' => $option->admin_name,
'sort_order' => $option->sort_order,
'swatch_value' => $option->swatch_value,
];
}
}
return $superAttrbutes;
}
}

View File

@ -5,7 +5,7 @@ namespace Webkul\Shop\Http\Controllers;
use Webkul\Shop\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Webkul\Core\Repositories\SliderRepository as Sliders;
use Webkul\Core\Repositories\SliderRepository;
/**
* Home page controller
@ -16,14 +16,16 @@ use Webkul\Core\Repositories\SliderRepository as Sliders;
class HomeController extends Controller
{
protected $_config;
protected $sliders;
protected $sliderRepository;
protected $current_channel;
public function __construct(Sliders $s)
public function __construct(SliderRepository $sliderRepository)
{
$this->_config = request('_config');
$this->sliders = $s;
$this->sliderRepository = $sliderRepository;
}
/**
@ -34,10 +36,10 @@ use Webkul\Core\Repositories\SliderRepository as Sliders;
if (request()->route('any'))
abort(404);
$current_channel = core()->getCurrentChannel();
$currentChannel = core()->getCurrentChannel();
$all_sliders = $this->sliders->findWhere(['channel_id' => $current_channel['id']]);
$sliderData = $this->sliderRepository->findWhere(['channel_id' => $currentChannel->id])->toArray();
return view($this->_config['view'])->with('sliderData', $all_sliders->toArray());
return view($this->_config['view'], compact('sliderData'));
}
}

View File

@ -4,7 +4,7 @@ Route::group(['middleware' => ['web', 'locale', 'theme', 'currency']], function
//Store front home
Route::get('/{any?}', 'Webkul\Shop\Http\Controllers\HomeController@index')->defaults('_config', [
'view' => 'shop::home.index'
])->name('shop.home.index');
])->where('any', '<>', 'mobile')->name('shop.home.index');
//subscription
//subscribe

View File

@ -21,7 +21,7 @@
{{-- Footer --}}
@slot('footer')
@component('mail::footer')
© {{ date('Y') }} {{ config('app.name') }}. @lang('All rights reserved.')
&copy; {{ date('Y') }} {{ config('app.name') }}. All rights reserved.
@endcomponent
@endslot
@endcomponent

View File

@ -21,7 +21,7 @@
{{-- Footer --}}
@slot('footer')
@component('mail::footer')
© {{ date('Y') }} {{ config('app.name') }}. @lang('All rights reserved.')
© {{ date('Y') }} {{ config('app.name') }}. All rights reserved.
@endcomponent
@endslot
@endcomponent

View File

@ -56,7 +56,7 @@
'into your web browser: [:actionURL](:actionURL)',
[
'actionText' => $actionText,
'actionURL' => $actionUrl,
'actionURL' => $actionUrl
]
)
@endcomponent