- Posts: 171
- Thank you received: 9
Filter export based on order custom field dropdown
- pepecortez
-
Topic Author
- Offline
Tried to figure it out, but do not find any relevant information connecting to filtering order list.
Do we have an option on to filter orders on orderlist page and on export page based on custom order fileds?
Maybe it can be just a hack, or some lines to be added to ordermarket/export_show.php and ordermarket/listing.php
Thanks again,
PePe
Please Log in or Create an account to join the conversation.
Can you describe me the kind of filtering you want to do for the export ?
Thanks
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
- pepecortez
-
Topic Author
- Offline
- Posts: 171
- Thank you received: 9
2.) Field: order_location: Dropdown Locations
3.) Field: product_costtype: Dropdown type of costs
Jerome wrote: Hi,
Can you describe me the kind of filtering you want to do for the export ?
Thanks
Please Log in or Create an account to join the conversation.
Does your custom fields are already dropdown custom fields ?
I am analyzing your requirements and, it should be possible thanks to overrides to have the wanted result but it could be easier to put the filters directly in the SQL query and not process the exported data manually in PHP.
But I will require more details about your custom fields in order to know if we can use them directly or not.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
- pepecortez
-
Topic Author
- Offline
- Posts: 171
- Thank you received: 9
Jerome wrote: Hi,
Does your custom fields are already dropdown custom fields ?
I am analyzing your requirements and, it should be possible thanks to overrides to have the wanted result but it could be easier to put the filters directly in the SQL query and not process the exported data manually in PHP.
But I will require more details about your custom fields in order to know if we can use them directly or not.
Regards,
Yes, they are already dropdown. Attach a few screenshots how they looks like to not misunderstood.
Please Log in or Create an account to join the conversation.
Sorry for the delay.
I analyzed your requirements in order to see if we can integrate something like that directly in the export system.
The idea was to add a new "display" option for the custom field to put it as a filter for the exports.
The main problem is that the custom field, depending his type, won't react the same. And if you have a dropdown without an "empty" element, you can't deactivate the filter by selecting an element in the list. It means that the system should be more complex to add a special checkbox or something like that : to deactivate a filter.
Today, you can do this stuff manually ; by overriding the view "export_show" and also create a custom plugin to add your filters in the export SQL query.
For the moment there is no trigger for that specific purpose but we will add them into HikaMarket and HikaShop. It think it will be a good improvement for customization.
In your "export_show" override, the best will be to create manually the dropdowns, because you can't re-use the custom field if there is no element in the list without any value (to not apply the filter) unless you always want to apply the filters and never do a global export.
The other solution is to integrate the system I described in the first part. But it will require some time and for the moment I am mostly focused on the new order system. After that I want to finish the product edition system with the support of characteristics.
So, I can add it in the TODO list, for sure, but I can't guarantee that it will be added in a short time.
Kind regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
- pepecortez
-
Topic Author
- Offline
- Posts: 171
- Thank you received: 9
You mentioned the customly added dropdown to export view. Could you give me a direction point/custom code snippet how to solve that?
Please Log in or Create an account to join the conversation.
So the idea is to override the view "ordermarket | export_show" in order to add new fields.
These fields will be read by the custom plugin to override the SQL query made for the export.
Because you do not have empty value in your custom field, you will have to put the dropdown manually
To do so, you have to edit the file "component/com_hikamarket/ordermarket/view.html.php" and put this code for the export
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
- pepecortez
-
Topic Author
- Offline
- Posts: 171
- Thank you received: 9
Dropdowns shown correctly, it's OK. (ordermarket | export_show)
Also added your code snippet to component/com_hikamarket/ordermarket/view.html.php
Tried to add "JRequest::getValue('filter_koltseg_jelleg', '') " but thrown out error in Joomla 3, also tried it with JRequest::get('filter_koltseg_jelleg', '') but nothing happened (maybe I put it to wrong place in the plugin )
So I tried an other way as I realized I should have to filter more fields as well.
In ordermarket | export_show I changed your code to this (and repeated it for all the necessary fields, with different datas).
For example:
In "component/com_hikamarket/ordermarket/view.html.php" I added:
and modified the SQL query to load the necessary fields:
Where am I wrong?
Please Log in or Create an account to join the conversation.
If you field is "data[export][filter_koltseghely", you can access it using JRequest::getVar('filter_koltseghely'), you have to get an array for the key "data".
Like you "did" for the rest of your code in the view
For the rest, like that I can't tell you. It looks good but I don't know the result.
I prefer to link product/order_product using the product_id and not the product_code..
Otherwise, I don't know what is wrong because I don't have the required information for that : what's the result ? What's the problem ?
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
- pepecortez
-
Topic Author
- Offline
- Posts: 171
- Thank you received: 9
The problem was the SQL syntax was OK, but as I exporting rows based on products by custom plugin, I used the extended new SQL query not in the right place.
Now using it before:
and now filtering correctly as I see.
Please Log in or Create an account to join the conversation.
- pepecortez
-
Topic Author
- Offline
- Posts: 171
- Thank you received: 9
There's a value option 0 in a dropdown:
If 0 is choosen SQL is not filtering for 0, show all values from the column. Looks like it's using value 0 as no filter. Is there a trick to solve that?
Please Log in or Create an account to join the conversation.
- pepecortez
-
Topic Author
- Offline
- Posts: 171
- Thank you received: 9
pepecortez wrote: Sorry, just catch a small problem:
There's a value option 0 in a dropdown:Code:<dt class="hikamarket_order_export_tovabbterhelesikod"><label><?php echo JText::_('Továbbterhelési kód:'); ?></label></dt> <dd class="hikamarket_order_export_tovabbterhelesikod"> <?php $values_tovabbterhelesikod = array( JHTML::_('select.option', '', JText::_('No filter')), JHTML::_('select.option', '0', '0'), JHTML::_('select.option', '1', '1'), JHTML::_('select.option', '2', '2'), JHTML::_('select.option', '3', '3'), JHTML::_('select.option', '4', '4') ); echo JHTML::_('select.genericlist', $values_tovabbterhelesikod, 'data[export][filter_tovabbterhelesikod]', '', 'value', 'text', ''); ?> </dd>
If 0 is choosen SQL is not filtering for 0, show all values from the column. Looks like it's using value 0 as no filter. Is there a trick to solve that?
Solution is checking value with isset and not with !empty:
or
Please Log in or Create an account to join the conversation.
Or, change the check
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.