Show tax category in products datagrid
-
Hi,
First of all thanks for this e-commerce solution. It's working well and is easy to customize.
I now have a situation where in the admin zone I have to include the tax category in the products datatable.
I have successfully added other columns, but this one won't work.The problem is I can't add the tax_category attribute to the
products_flat
table since it's a non-user defined attribute.
So inAdmin\src\Datagrids\ProductDataGrid
I can't do something like$q->select('product_flat.tax_category_id')
.Is there a way to make the query include the tax category?
Thanks in advance!
-
Hi there,
Are you trying to add tax for any product ? -
Hello Sanjay,
Thanks for your reaction.
Adding tax for a product is not a problem.What I want is, in the products table / datagrid under catalog -> products, to show the tax category.
By default it showsID
,SKU
,name
,Attribute Family
,Type
,Status
,Price
andQuantity
.I was able to add some columns like
weight
andfeatured
.
But I also need to display thetax category
in that table. Do you know how I can achieve this?I hope my explanation is clear. If not, let me know!
-
@Yorg said in Show tax category in products datagrid:
tax category
Hi there,
You need to change here -
Hi Sanjay,
I still can't get this to work.
I added the following:$this->addColumn([ 'index' => 'tax_category_id', 'label' => 'Tax category', 'type' => 'number', 'searchable' => false, 'sortable' => true, 'filterable' => true, ]);
The column shows, but is empty.
I made sure the products have a tax category assigned to them. -
Hi there,
Please get the tax-category field from the database first then try to add into the data grid column, please take a reference from Here -
Hi Sanjay,
Thanks for your response!
That's kind of where I'm stuck. I added'product_flat.tax_category_id'
to the select, but I get an errorColumn not found: 1054 Unknown column 'product_flat.tax_category_id' in 'field list'
Also'products.tax_category_id'
won't work.Do I need to do some extra joins or something?
-
Hi there,
Which version of Bagisto are you using? -
We are using a forked version of 1.3.2.
-
@Yorg said in Show tax category in products datagrid:
tax_category_id
Hi there,
The tax_category_id filed is not in product_flat table. so you are getting this error.