Skip to content

Commit

Permalink
Merge pull request #3677 from devansh-webkul/product_name_blank_issue
Browse files Browse the repository at this point in the history
Fixed #3507, #3656 and #3692
  • Loading branch information
jitendra-webkul committed Aug 10, 2020
2 parents aea0e37 + 2487f5f commit 34b0613
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php
Expand Up @@ -4,6 +4,7 @@

use Webkul\Ui\DataGrid\DataGrid;
use Illuminate\Support\Facades\DB;
use Webkul\Core\Models\Channel;

class ProductDataGrid extends DataGrid
{
Expand All @@ -27,18 +28,29 @@ public function __construct()
{
parent::__construct();

/* locale */
$this->locale = request()->get('locale') ?? 'all';

/* channel */
$this->channel = request()->get('channel') ?? 'all';

/* finding channel name */
if ($this->channel !== 'all') {
$this->channel = Channel::find($this->channel);
$this->channel = $this->channel ? $this->channel->code : 'all';
}
}

public function prepareQueryBuilder()
{
/* query builder */
$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.locale',
'product_flat.channel',
'product_flat.product_id as product_id',
'products.sku as product_sku',
'product_flat.name as product_name',
Expand All @@ -58,6 +70,8 @@ public function prepareQueryBuilder()
}

$queryBuilder->groupBy('product_flat.product_id');
$queryBuilder->having('locale', $this->locale !== 'all' ? $this->locale : 'en');
$queryBuilder->having('channel', $this->channel !== 'all' ? $this->channel : 'default');

$this->addFilter('product_id', 'product_flat.product_id');
$this->addFilter('product_name', 'product_flat.name');
Expand Down

0 comments on commit 34b0613

Please sign in to comment.