Merge branch 'master' of https://github.com/bagisto/bagisto into development
This commit is contained in:
commit
c64bb4f85b
|
|
@ -3,7 +3,7 @@
|
|||
namespace Webkul\Admin\DataGrids;
|
||||
|
||||
use Webkul\Ui\DataGrid\DataGrid;
|
||||
use DB;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* ProductDataGrid Class
|
||||
|
|
@ -19,16 +19,44 @@ class ProductDataGrid extends DataGrid
|
|||
|
||||
protected $itemsPerPage = 10;
|
||||
|
||||
protected $locale = 'all';
|
||||
|
||||
protected $channel = 'all';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->locale = request()->get('locale') ?? 'all';
|
||||
$this->channel = request()->get('channel') ?? 'all';
|
||||
}
|
||||
|
||||
public function prepareQueryBuilder()
|
||||
{
|
||||
$queryBuilder = DB::table('product_flat')
|
||||
->leftJoin('products', 'product_flat.product_id', '=', 'products.id')
|
||||
->leftJoin('attribute_families', 'products.attribute_family_id', '=', 'attribute_families.id')
|
||||
->leftJoin('product_inventories', 'product_flat.product_id', '=', 'product_inventories.product_id')
|
||||
->select('product_flat.product_id as product_id', 'products.sku as product_sku', 'product_flat.name as product_name', 'products.type as product_type', 'product_flat.status', 'product_flat.price', 'attribute_families.name as attribute_family', DB::raw('SUM(' . DB::getTablePrefix() . 'product_inventories.qty) as quantity'))
|
||||
->where('channel', core()->getCurrentChannelCode())
|
||||
->where('locale', app()->getLocale())
|
||||
->groupBy('product_flat.product_id');
|
||||
->select(
|
||||
'product_flat.product_id as product_id',
|
||||
'products.sku as product_sku',
|
||||
'product_flat.name as product_name',
|
||||
'products.type as product_type',
|
||||
'product_flat.status',
|
||||
'product_flat.price',
|
||||
'attribute_families.name as attribute_family',
|
||||
DB::raw('SUM(' . DB::getTablePrefix() . 'product_inventories.qty) as quantity')
|
||||
);
|
||||
|
||||
if ($this->locale !== 'all') {
|
||||
$queryBuilder->where('locale', $this->locale);
|
||||
}
|
||||
|
||||
if ($this->channel !== 'all') {
|
||||
$queryBuilder->where('channel', $this->channel);
|
||||
}
|
||||
|
||||
$queryBuilder->groupBy('product_flat.product_id');
|
||||
|
||||
$this->addFilter('product_id', 'product_flat.product_id');
|
||||
$this->addFilter('product_name', 'product_flat.name');
|
||||
|
|
|
|||
|
|
@ -776,7 +776,8 @@ return [
|
|||
'seo' => 'Home page SEO',
|
||||
'seo-title' => 'Meta title',
|
||||
'seo-description' => 'Meta description',
|
||||
'seo-keywords' => 'Meta keywords'
|
||||
'seo-keywords' => 'Meta keywords',
|
||||
|
||||
],
|
||||
|
||||
'sliders' => [
|
||||
|
|
@ -1263,7 +1264,9 @@ return [
|
|||
'order-number-length' => 'Order Number Length',
|
||||
'order-number-suffix' => 'Order Number Suffix',
|
||||
'default' => 'Default',
|
||||
'sandbox' => 'Sandbox'
|
||||
'sandbox' => 'Sandbox',
|
||||
'all-channels' => 'All',
|
||||
'all-locales' => 'All'
|
||||
]
|
||||
]
|
||||
];
|
||||
|
|
|
|||
|
|
@ -6,9 +6,45 @@
|
|||
|
||||
@section('content')
|
||||
<div class="content" style="height: 100%;">
|
||||
<?php $locale = request()->get('locale') ?: null; ?>
|
||||
<?php $channel = request()->get('channel') ?: null; ?>
|
||||
<div class="page-header">
|
||||
<div class="page-title">
|
||||
<h1>{{ __('admin::app.catalog.products.title') }}</h1>
|
||||
|
||||
<div class="control-group">
|
||||
<select class="control" id="channel-switcher" name="channel" onchange="reloadPage('channel', this.value)" >
|
||||
<option value="all" {{ ! isset($channel) ? 'selected' : '' }}>
|
||||
{{ __('admin::app.admin.system.all-channels') }}
|
||||
</option>
|
||||
|
||||
@foreach (core()->getAllChannels() as $channelModel)
|
||||
|
||||
<option
|
||||
value="{{ $channelModel->code }}" {{ (isset($channel) && ($channelModel->code) == $channel) ? 'selected' : '' }}>
|
||||
{{ $channelModel->name }}
|
||||
</option>
|
||||
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<select class="control" id="locale-switcher" name="locale" onchange="reloadPage('locale', this.value)" >
|
||||
<option value="all" {{ ! isset($locale) ? 'selected' : '' }}>
|
||||
{{ __('admin::app.admin.system.all-locales') }}
|
||||
</option>
|
||||
|
||||
@foreach (core()->getAllLocales() as $localeModel)
|
||||
|
||||
<option
|
||||
value="{{ $localeModel->code }}" {{ (isset($locale) && ($localeModel->code) == $locale) ? 'selected' : '' }}>
|
||||
{{ $localeModel->name }}
|
||||
</option>
|
||||
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="page-action">
|
||||
|
|
@ -46,4 +82,14 @@
|
|||
|
||||
@push('scripts')
|
||||
@include('admin::export.export', ['gridName' => $products])
|
||||
<script>
|
||||
|
||||
function reloadPage(getVar, getVal) {
|
||||
let url = new URL(window.location.href);
|
||||
url.searchParams.set(getVar, getVal);
|
||||
|
||||
window.location.href = url.href;
|
||||
}
|
||||
|
||||
</script>
|
||||
@endpush
|
||||
|
|
@ -170,7 +170,7 @@ class CategoryController extends Controller
|
|||
session()->flash('warning', trans('admin::app.response.delete-category-root', ['name' => 'Category']));
|
||||
} else {
|
||||
try {
|
||||
Event:: fire('catalog.category.delete.before', $id);
|
||||
Event::dispatch('catalog.category.delete.before', $id);
|
||||
|
||||
$this->categoryRepository->delete($id);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Webkul\Checkout\Models\CartAddress;
|
||||
|
||||
$factory->define(CartAddress::class, function (Faker $faker) {
|
||||
$now = date("Y-m-d H:i:s");
|
||||
return [
|
||||
'first_name' => $faker->firstName(),
|
||||
'last_name' => $faker->lastName,
|
||||
'email' => $faker->email,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
'address_type' => 'billing',
|
||||
];
|
||||
});
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
use Webkul\Customer\Models\Customer;
|
||||
use Webkul\Checkout\Models\Cart;
|
||||
use Webkul\Checkout\Models\CartAddress;
|
||||
|
||||
$factory->define(Cart::class, function (Faker $faker) {
|
||||
$now = date("Y-m-d H:i:s");
|
||||
|
||||
$lastOrder = DB::table('orders')
|
||||
->orderBy('id', 'desc')
|
||||
->select('id')
|
||||
->first();
|
||||
|
||||
$customer = factory(Customer::class)->create();
|
||||
$cartAddress = factory(CartAddress::class)->create();
|
||||
|
||||
return [
|
||||
'is_guest' => 0,
|
||||
'is_active' => 1,
|
||||
'customer_id' => $customer->id,
|
||||
'customer_email' => $customer->email,
|
||||
'customer_first_name' => $customer->first_name,
|
||||
'customer_last_name' => $customer->last_name,
|
||||
'is_gift' => 0,
|
||||
'base_currency_code' => 'EUR',
|
||||
'channel_currency_code' => 'EUR',
|
||||
'grand_total' => 0.0000,
|
||||
'base_grand_total' => 0.0000,
|
||||
'sub_total' => 0.0000,
|
||||
'base_sub_total' => 0.0000,
|
||||
'channel_id' => 1,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
];
|
||||
});
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Webkul\Checkout\Models\CartItem;
|
||||
|
||||
$factory->define(CartItem::class, function (Faker $faker) {
|
||||
$now = date("Y-m-d H:i:s");
|
||||
|
||||
return [
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
];
|
||||
});
|
||||
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Webkul\Checkout\Models\CartPayment;
|
||||
|
||||
$factory->define(CartPayment::class, function (Faker $faker) {
|
||||
$now = date("Y-m-d H:i:s");
|
||||
|
||||
return [
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
];
|
||||
});
|
||||
|
||||
|
|
@ -5,6 +5,7 @@ namespace Webkul\Checkout\Providers;
|
|||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Foundation\AliasLoader;
|
||||
use Webkul\Checkout\Facades\Cart;
|
||||
use Illuminate\Database\Eloquent\Factory as EloquentFactory;
|
||||
|
||||
class CheckoutServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
|
@ -17,6 +18,8 @@ class CheckoutServiceProvider extends ServiceProvider
|
|||
$this->app->register(ModuleServiceProvider::class);
|
||||
|
||||
$this->app->register(EventServiceProvider::class);
|
||||
|
||||
$this->registerEloquentFactoriesFrom(__DIR__ . '/../Database/Factories');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -48,4 +51,16 @@ class CheckoutServiceProvider extends ServiceProvider
|
|||
|
||||
$this->app->bind('cart', 'Webkul\Checkout\Cart');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register factories.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerEloquentFactoriesFrom($path): void
|
||||
{
|
||||
$this->app->make(EloquentFactory::class)->load($path);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Webkul\Core\Models\Currency;
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
$factory->define(Currency::class, function (Faker $faker, array $attributes) {
|
||||
|
||||
return [
|
||||
'code' => $faker->unique()->currencyCode,
|
||||
'name' => $faker->word,
|
||||
];
|
||||
|
||||
});
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Webkul\Core\Models\Locale;
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
$factory->define(Locale::class, function (Faker $faker, array $attributes) {
|
||||
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace Webkul\Inventory\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Database\Eloquent\Factory as EloquentFactory;
|
||||
|
||||
class InventoryServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
|
@ -14,6 +15,8 @@ class InventoryServiceProvider extends ServiceProvider
|
|||
public function boot()
|
||||
{
|
||||
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
|
||||
|
||||
$this->app->make(EloquentFactory::class)->load(__DIR__ . '/../Database/Factories');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Webkul\Product\Models\ProductDownloadableLink;
|
||||
use Webkul\Product\Models\ProductDownloadableLinkTranslation;
|
||||
|
||||
$factory->define(ProductDownloadableLink::class, function (Faker $faker) {
|
||||
$now = date("Y-m-d H:i:s");
|
||||
$filename = 'ProductImageExampleForUpload.jpg';
|
||||
$filepath = '/tests/_data/';
|
||||
return [
|
||||
'url' => '',
|
||||
'file' => $filepath . $filename,
|
||||
'file_name' => $filename,
|
||||
'type' => 'file',
|
||||
'price' => 0.0000,
|
||||
'downloads' => $faker->randomNumber(1),
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(ProductDownloadableLinkTranslation::class, function (Faker $faker) {
|
||||
return [
|
||||
'locale' => 'en',
|
||||
'title' => $faker->word,
|
||||
];
|
||||
});
|
||||
|
||||
|
|
@ -19,6 +19,8 @@ class ProductServiceProvider extends ServiceProvider
|
|||
{
|
||||
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
|
||||
|
||||
$this->app->make(EloquentFactory::class)->load(__DIR__ . '/../Database/Factories');
|
||||
|
||||
$this->app->register(EventServiceProvider::class);
|
||||
|
||||
$this->publishes([
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Webkul\Product\Models\Product;
|
||||
use Webkul\Sales\Models\Invoice;
|
||||
use Webkul\Sales\Models\InvoiceItem;
|
||||
use Webkul\Sales\Models\OrderItem;
|
||||
|
||||
$factory->define(InvoiceItem::class, function (Faker $faker, array $attributes) {
|
||||
|
||||
$basePrice = $faker->randomFloat(2);
|
||||
$quantity = $faker->randomNumber();
|
||||
|
||||
if (! $attributes['order_item_id']) {
|
||||
$attributes['order_item_id'] = function () {
|
||||
return factory(OrderItem::class)->create()->id;
|
||||
};
|
||||
}
|
||||
|
||||
$orderItem = OrderItem::find($attributes['order_item_id']);
|
||||
|
||||
return [
|
||||
'name' => $faker->word,
|
||||
'sku' => $faker->unique()->ean13,
|
||||
'qty' => $quantity,
|
||||
'price' => $basePrice,
|
||||
'base_price' => $basePrice,
|
||||
'total' => $quantity * $basePrice,
|
||||
'base_total' => $quantity * $basePrice,
|
||||
'tax_amount' => 0,
|
||||
'base_tax_amount' => 0,
|
||||
'product_id' => $orderItem->product_id,
|
||||
'product_type' => $orderItem->product_type,
|
||||
'order_item_id' => $attributes['order_item_id'],
|
||||
'invoice_id' => function () {
|
||||
return factory(Invoice::class)->create()->id;
|
||||
},
|
||||
];
|
||||
});
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Webkul\Product\Models\Product;
|
||||
use Webkul\Sales\Models\Order;
|
||||
use Webkul\Sales\Models\OrderItem;
|
||||
|
||||
$factory->define(OrderItem::class, function (Faker $faker) {
|
||||
$now = date("Y-m-d H:i:s");
|
||||
|
||||
$product = factory(Product::class, 'simple')->create();
|
||||
|
||||
return [
|
||||
'sku' => $product->sku,
|
||||
'type' => $product->type,
|
||||
'name' => $product->name,
|
||||
'price' => $product->price,
|
||||
'base_price' => $product->price,
|
||||
'total' => $product->price,
|
||||
'base_total' => $product->price,
|
||||
'product_id' => $product->id,
|
||||
'qty_ordered' => 1,
|
||||
'qty_shipped' => 0,
|
||||
'qty_invoiced' => 0,
|
||||
'qty_canceled' => 0,
|
||||
'qty_refunded' => 0,
|
||||
'order_id' => function () {
|
||||
return factory(Order::class)->create()->id;
|
||||
},
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Webkul\Sales\Models\OrderPayment;
|
||||
|
||||
$factory->define(OrderPayment::class, function (Faker $faker) {
|
||||
$now = date("Y-m-d H:i:s");
|
||||
|
||||
return [
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
];
|
||||
});
|
||||
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"/js/ui.js": "/js/ui.js?id=fc16a516045fc2b1ab87",
|
||||
"/js/ui.js": "/js/ui.js?id=d4f31631ea9c862c6dc5",
|
||||
"/css/ui.css": "/css/ui.css?id=0895b560bbc19259cee8"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,10 @@
|
|||
},
|
||||
|
||||
created () {
|
||||
let index = this.savedValues.indexOf(this.items[this.valueField])
|
||||
if (! this.savedValues)
|
||||
return;
|
||||
|
||||
let index = this.savedValues.indexOf(this.items[this.valueField].toString())
|
||||
if(index !== -1) {
|
||||
this.value.push(this.items);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@
|
|||
|
||||
computed: {
|
||||
savedValues () {
|
||||
if(!this.value)
|
||||
if(! this.value)
|
||||
return [];
|
||||
|
||||
if(this.inputType == 'radio')
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Tests\Functional\Admin\Catalog;
|
||||
|
||||
|
||||
use FunctionalTester;
|
||||
use Webkul\Attribute\Models\Attribute;
|
||||
|
||||
|
|
@ -76,7 +75,7 @@ class AttributeCest
|
|||
private function fillForm(FunctionalTester $I, bool $skipType = false): array
|
||||
{
|
||||
$testData = [
|
||||
'code' => $I->fake()->word,
|
||||
'code' => $I->fake()->firstName,
|
||||
'type' => $I->fake()->randomElement([
|
||||
'text',
|
||||
'textarea',
|
||||
|
|
@ -85,7 +84,7 @@ class AttributeCest
|
|||
'select',
|
||||
'multiselect'
|
||||
]),
|
||||
'admin_name' => $I->fake()->word,
|
||||
'admin_name' => $I->fake()->firstName,
|
||||
];
|
||||
|
||||
$I->fillField('code', $testData['code']);
|
||||
|
|
|
|||
Loading…
Reference in New Issue