Jump to content

Custom admin order column showing suppliers


bobrupholdt

Recommended Posts

Using PS 1.6.1.9 and want to be able to filter the list by supplier.  I've added custom columns successfully but can't figure out the query for this one.  In mysql I can get the correct data using the below query but just don't know enough to get this in my AdminOrdersController override.

 

select GROUP_CONCAT(s.name SEPARATOR ', ') as suppliers
from ps_orders o 
join ps_order_detail d on d.id_order = o.id_order
join ps_product p on p.id_product = d.product_id
join ps_supplier s on s.id_supplier = p.id_supplier
where o.id_order = $ORDERID
group by o.id_order
order by o.id_order desc

 

Link to comment
Share on other sites

It's more complicated than you might think.

 

First of all, you cannot make just one new own query. You would have to add your filter field to the EXISTING query instead. Otherwise you would loose the general filters from the order admin page.

 

Second: you had to change the corresponding form (tpl file) for the admin order page in order to have your supplier field show. It's not enough to fetch the data from the database. You have to bring it on screen as well.

 

You have to make your SQL adaptive, so it only selects suppliers, if the field is set and somehow valid.

Edited by Scully (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...