commit
7e8e42c698
|
|
@ -0,0 +1,199 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Admin\DataGrids;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Webkul\Core\Models\Channel;
|
||||
use Webkul\Core\Models\Locale;
|
||||
use Webkul\Ui\DataGrid\DataGrid;
|
||||
|
||||
class CategoryProductDataGrid extends DataGrid
|
||||
{
|
||||
/**
|
||||
* Default sort order of datagrid.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $sortOrder = 'desc';
|
||||
|
||||
/**
|
||||
* Set index columns, ex: id.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $index = 'product_id';
|
||||
|
||||
/**
|
||||
* If paginated then value of pagination.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $itemsPerPage = 10;
|
||||
|
||||
/**
|
||||
* Locale.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $locale;
|
||||
|
||||
/**
|
||||
* Channel.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $channel;
|
||||
|
||||
/**
|
||||
* Create datagrid instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
/* locale */
|
||||
$this->locale = core()->getRequestedLocaleCode();
|
||||
|
||||
/* channel */
|
||||
$this->channel = core()->getRequestedChannelCode();
|
||||
|
||||
/* parent constructor */
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare query builder.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function prepareQueryBuilder()
|
||||
{
|
||||
/* query builder */
|
||||
$queryBuilder = DB::table('product_flat')
|
||||
->leftJoin('products', 'product_flat.product_id', '=', 'products.id')
|
||||
->leftJoin('product_categories', 'products.id', '=', 'product_categories.product_id')
|
||||
->leftJoin('product_inventories', 'product_flat.product_id', '=', 'product_inventories.product_id')
|
||||
->select(
|
||||
'product_flat.locale',
|
||||
'product_flat.channel',
|
||||
'product_flat.product_id',
|
||||
'products.sku as product_sku',
|
||||
'product_flat.product_number',
|
||||
'product_flat.name as product_name',
|
||||
'products.type as product_type',
|
||||
'product_flat.status',
|
||||
'product_flat.price',
|
||||
);
|
||||
|
||||
$queryBuilder->groupBy('product_flat.product_id', 'product_flat.locale', 'product_flat.channel');
|
||||
|
||||
$queryBuilder->where('product_categories.category_id', request('id'));
|
||||
$queryBuilder->whereIn('product_flat.locale', [$this->locale]);
|
||||
$queryBuilder->whereIn('product_flat.channel', [$this->channel]);
|
||||
|
||||
$this->addFilter('product_id', 'product_flat.product_id');
|
||||
$this->addFilter('product_name', 'product_flat.name');
|
||||
$this->addFilter('product_sku', 'products.sku');
|
||||
$this->addFilter('product_number', 'product_flat.product_number');
|
||||
$this->addFilter('status', 'product_flat.status');
|
||||
$this->addFilter('product_type', 'products.type');
|
||||
|
||||
$this->setQueryBuilder($queryBuilder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add columns.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addColumns()
|
||||
{
|
||||
$this->addColumn([
|
||||
'index' => 'product_id',
|
||||
'label' => trans('admin::app.datagrid.id'),
|
||||
'type' => 'number',
|
||||
'searchable' => false,
|
||||
'sortable' => true,
|
||||
'filterable' => true,
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
'index' => 'product_sku',
|
||||
'label' => trans('admin::app.datagrid.sku'),
|
||||
'type' => 'string',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'filterable' => true,
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
'index' => 'product_number',
|
||||
'label' => trans('admin::app.datagrid.product-number'),
|
||||
'type' => 'string',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'filterable' => true,
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
'index' => 'product_name',
|
||||
'label' => trans('admin::app.datagrid.name'),
|
||||
'type' => 'string',
|
||||
'searchable' => true,
|
||||
'sortable' => true,
|
||||
'filterable' => true,
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
'index' => 'product_type',
|
||||
'label' => trans('admin::app.datagrid.type'),
|
||||
'type' => 'string',
|
||||
'sortable' => true,
|
||||
'searchable' => true,
|
||||
'filterable' => true,
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
'index' => 'status',
|
||||
'label' => trans('admin::app.datagrid.status'),
|
||||
'type' => 'boolean',
|
||||
'sortable' => true,
|
||||
'searchable' => false,
|
||||
'filterable' => true,
|
||||
'closure' => function ($value) {
|
||||
if ($value->status == 1) {
|
||||
return trans('admin::app.datagrid.active');
|
||||
} else {
|
||||
return trans('admin::app.datagrid.inactive');
|
||||
}
|
||||
},
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
'index' => 'price',
|
||||
'label' => trans('admin::app.datagrid.price'),
|
||||
'type' => 'price',
|
||||
'sortable' => true,
|
||||
'searchable' => false,
|
||||
'filterable' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare actions.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function prepareActions()
|
||||
{
|
||||
$this->addAction([
|
||||
'title' => trans('admin::app.datagrid.edit'),
|
||||
'method' => 'GET',
|
||||
'route' => 'admin.catalog.products.edit',
|
||||
'icon' => 'icon pencil-lg-icon',
|
||||
'condition' => function () {
|
||||
return true;
|
||||
},
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -699,6 +699,7 @@ return [
|
|||
'description' => 'الوصف',
|
||||
'parent-category' => 'الفئة الأم',
|
||||
'seo' => 'محرك البحث الأمثل',
|
||||
'products' => 'المنتجات',
|
||||
'slug' => 'Slug',
|
||||
'meta_title' => 'عنوان الفوقية',
|
||||
'meta_description' => 'ميتا الوصف',
|
||||
|
|
|
|||
|
|
@ -691,6 +691,7 @@ return [
|
|||
'description' => 'Beschreibung',
|
||||
'parent-category' => 'Übergeordnete Kategorie',
|
||||
'seo' => 'Suchmaschinen-Optimierung',
|
||||
'products' => 'Produkte',
|
||||
'slug' => 'Slug',
|
||||
'meta_title' => 'Meta Titel',
|
||||
'meta_description' => 'Meta-Beschreibung',
|
||||
|
|
|
|||
|
|
@ -709,6 +709,7 @@ return [
|
|||
'description' => 'Description',
|
||||
'parent-category' => 'Parent Category',
|
||||
'seo' => 'Search Engine Optimization',
|
||||
'products' => 'Products',
|
||||
'slug' => 'Slug',
|
||||
'meta_title' => 'Meta Title',
|
||||
'meta_description' => 'Meta Description',
|
||||
|
|
|
|||
|
|
@ -710,6 +710,7 @@ return [
|
|||
'description' => 'Descripción',
|
||||
'parent-category' => 'Categoría padre',
|
||||
'seo' => 'SEO',
|
||||
'products' => 'Productos',
|
||||
'slug' => 'Slug',
|
||||
'meta_title' => 'Meta Title',
|
||||
'meta_description' => 'Meta Description',
|
||||
|
|
|
|||
|
|
@ -687,6 +687,7 @@ return [
|
|||
'description' => 'توضیحات',
|
||||
'parent-category' => 'دسته بندی پدر',
|
||||
'seo' => 'بهینه سازی موتور جستجو',
|
||||
'products' => 'محصولات',
|
||||
'slug' => 'نامک',
|
||||
'meta_title' => 'عنوان متا',
|
||||
'meta_description' => 'توضیحات متا',
|
||||
|
|
|
|||
|
|
@ -711,6 +711,7 @@ return [
|
|||
'description' => 'La description',
|
||||
'parent-category' => 'Catégorie Parentale',
|
||||
'seo' => 'optimisation du moteur de recherche',
|
||||
'products' => 'Des produits',
|
||||
'slug' => 'Limace',
|
||||
'meta_title' => 'Titre du méta',
|
||||
'meta_description' => 'Meta Description',
|
||||
|
|
|
|||
|
|
@ -709,6 +709,7 @@ return [
|
|||
'description' => 'विवरण',
|
||||
'parent-category' => 'अभिभावक श्रेणी',
|
||||
'seo' => 'खोज इंजिन अनुकूलन',
|
||||
'products' => 'उत्पाद',
|
||||
'slug' => 'स्लग',
|
||||
'meta_title' => 'मेटा शीर्षक',
|
||||
'meta_description' => 'मेटा विवरण',
|
||||
|
|
|
|||
|
|
@ -690,6 +690,7 @@ return [
|
|||
'parent-category' => 'Categoria Padre',
|
||||
'seo' => 'Search Engine Optimization',
|
||||
'slug' => 'Slug',
|
||||
'products' => 'Prodotti',
|
||||
'meta_title' => 'Meta Title',
|
||||
'meta_description' => 'Meta Description',
|
||||
'meta_keywords' => 'Meta Keywords',
|
||||
|
|
|
|||
|
|
@ -686,6 +686,7 @@ return [
|
|||
'description' => 'Beschrijving',
|
||||
'parent-category' => 'Bovenliggende categorie',
|
||||
'seo' => 'zoek machine optimalisatie',
|
||||
'products' => 'Producten',
|
||||
'slug' => 'Slug',
|
||||
'meta_title' => 'Metatitel',
|
||||
'meta_description' => 'Meta omschrijving',
|
||||
|
|
|
|||
|
|
@ -686,6 +686,7 @@ return [
|
|||
'description' => 'Opis',
|
||||
'parent-category' => 'Kategoria nadrzędna',
|
||||
'seo' => 'Optymalizacja SEO strony dla wyszukiwarek',
|
||||
'products' => 'Produkty',
|
||||
'slug' => 'Wzór',
|
||||
'meta_title' => 'Meta tutuł',
|
||||
'meta_description' => 'Meta opis',
|
||||
|
|
|
|||
|
|
@ -685,6 +685,7 @@ return [
|
|||
'description' => 'Descrição',
|
||||
'parent-category' => 'Categoria Pai',
|
||||
'seo' => 'Search Engine Optimization',
|
||||
'products' => 'Produtos',
|
||||
'slug' => 'Slug',
|
||||
'meta_title' => 'Meta Título',
|
||||
'meta_description' => 'Meta Descrição',
|
||||
|
|
|
|||
|
|
@ -692,6 +692,7 @@ return [
|
|||
'description' => 'Açıklama',
|
||||
'parent-category' => 'Üst Kategori',
|
||||
'seo' => 'Arama Motoru Optimizasyonu',
|
||||
'products' => 'Ürünler',
|
||||
'slug' => 'URL',
|
||||
'meta_title' => 'Meta Başlığı',
|
||||
'meta_description' => 'Meta Açıklaması',
|
||||
|
|
|
|||
|
|
@ -694,6 +694,7 @@ return [
|
|||
'description' => '描述',
|
||||
'parent-category' => '父分类',
|
||||
'seo' => '搜索引擎优化',
|
||||
'products' => '产品列表',
|
||||
'slug' => 'Slug',
|
||||
'meta_title' => 'Meta标题',
|
||||
'meta_description' => 'Meta描述',
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@
|
|||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.create_form_accordian.seo.before') !!}
|
||||
|
||||
<accordian title="'{{ __('admin::app.catalog.categories.seo') }}" :active="true">
|
||||
<accordian title="{{ __('admin::app.catalog.categories.seo') }}" :active="true">
|
||||
<div slot="body">
|
||||
{!! view_render_event('bagisto.admin.catalog.category.create_form_accordian.seo.controls.before') !!}
|
||||
|
||||
|
|
|
|||
|
|
@ -216,6 +216,16 @@
|
|||
</div>
|
||||
</accordian>
|
||||
|
||||
<accordian title="{{ __('admin::app.catalog.categories.products') }}" :active="true">
|
||||
<div slot="body">
|
||||
{!! view_render_event('bagisto.admin.catalog.category.edit_form_accordian.products.controls.before', ['category' => $category]) !!}
|
||||
|
||||
<datagrid-plus src="{{ route('admin.catalog.categories.products', $category->id) }}"></datagrid-plus>
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.edit_form_accordian.products.controls.before', ['category' => $category]) !!}
|
||||
</div>
|
||||
</accordian>
|
||||
|
||||
{!! view_render_event('bagisto.admin.catalog.category.edit_form_accordian.seo.after', ['category' => $category]) !!}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
<input name="_method" type="hidden" value="PUT">
|
||||
|
||||
<accordian title="'{{ __('admin::app.account.general') }}" :active="true">
|
||||
<accordian title="{{ __('admin::app.account.general') }}" :active="true">
|
||||
<div slot="body">
|
||||
|
||||
<div class="control-group">
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
{!! view_render_event('bagisto.admin.settings.channel.create.before') !!}
|
||||
|
||||
{{-- general --}}
|
||||
<accordian title="'{{ __('admin::app.settings.channels.general') }}" :active="true">
|
||||
<accordian title="{{ __('admin::app.settings.channels.general') }}" :active="true">
|
||||
<div slot="body">
|
||||
|
||||
<div class="control-group" :class="[errors.has('code') ? 'has-error' : '']">
|
||||
|
|
@ -141,7 +141,7 @@
|
|||
</accordian>
|
||||
|
||||
{{-- design --}}
|
||||
<accordian title="'{{ __('admin::app.settings.channels.design') }}" :active="true">
|
||||
<accordian title="{{ __('admin::app.settings.channels.design') }}" :active="true">
|
||||
<div slot="body">
|
||||
<div class="control-group">
|
||||
<label for="theme">{{ __('admin::app.settings.channels.theme') }}</label>
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@
|
|||
</div>
|
||||
</accordian>
|
||||
|
||||
<accordian title="'{{ __('admin::app.settings.inventory_sources.address') }}" :active="true">
|
||||
<accordian title="{{ __('admin::app.settings.inventory_sources.address') }}" :active="true">
|
||||
<div slot="body">
|
||||
|
||||
@include ('admin::customers.country-state', ['countryCode' => old('country') ?? $inventorySource->country, 'stateCode' => old('state') ?? $inventorySource->state])
|
||||
|
|
|
|||
|
|
@ -96,6 +96,8 @@ Route::group(['middleware' => ['web', 'admin', 'admin_locale'], 'prefix' => conf
|
|||
'redirect' => 'admin.catalog.categories.index',
|
||||
])->name('admin.catalog.categories.update');
|
||||
|
||||
Route::get('/categories/products/{id}', [CategoryController::class, 'products'])->name('admin.catalog.categories.products');
|
||||
|
||||
Route::post('/categories/delete/{id}', [CategoryController::class, 'destroy'])->name('admin.catalog.categories.delete');
|
||||
|
||||
Route::post('categories/massdelete', [CategoryController::class, 'massDestroy'])->defaults('_config', [
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace Webkul\Category\Http\Controllers;
|
||||
|
||||
use Webkul\Admin\DataGrids\CategoryDataGrid;
|
||||
use Webkul\Admin\DataGrids\CategoryProductDataGrid;
|
||||
use Webkul\Attribute\Repositories\AttributeRepository;
|
||||
use Webkul\Category\Http\Requests\CategoryRequest;
|
||||
use Webkul\Category\Repositories\CategoryRepository;
|
||||
|
|
@ -109,6 +110,19 @@ class CategoryController extends Controller
|
|||
return view($this->_config['view'], compact('category', 'categories', 'attributes'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the products of specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function products($id)
|
||||
{
|
||||
if (request()->ajax()) {
|
||||
return app(CategoryProductDataGrid::class)->toJson();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue