Page 1 of 1

[SOLVED] - Settings not persistent?

Posted: Mon Jun 15, 2020 3:18 am
by LDeeJay
Lectori Salutem,

I've created a custom report (a copy of the product_purchased) and everything is working fine. It's showing up in the report drop down list, I can give access to it to other users and the report is reporting like it's supposed to... until..... I change something in the settings (under Extensions/Extensions/Reports). As soon as I hit the save button, the specific keys (report_product_purchased_myown) are removed from the oc_setting table and the report is disabled. No way I can enable it again, unless I recreate the keys (status & sort_order) manually in the oc_setting table. Can't be right.... right?

I've read about bugs of settings not being persistent but is this one of these cases? If so, what's the best way to resolve this? Or is there something else going on? Is there proper documentation on how to add custom reports because most of the official stuff refers to v2.

My workflow was as follows:
- Create the new files under controller, language, model & view
- Add the keys to oc_settings
- Give access & modify permissions under Users/Groups
- Activate the report under Extensions/Extensions/Reports

At first I didn't pay attention to the last step since I already entered it as 'activated' in step 2. But when I changed it, it wouldn't activate anymore and the keys were gone from oc_settings. What's the 'official' way of entering these keys? With an installation method? Can I read about that somewhere? In the past I was able to get by with the forum as documentation but with this reporting stuff I'm at a loss so apologies for any noob-questions.

Thanks for your time.

Leon

Tech details:
Opencart Version 3.0.3.2
Mods: Export/Import Tool (V3.22) for OpenCart, Remove Short Description, TMD Custom Tab , [underr] Order Invoice - Images
Layout/Theme: default
URL: newshop.bricks2spare.com (irrelevant)

Re: Settings not persistent?

Posted: Mon Jun 15, 2020 8:56 am
by straightlight
The right method would be to build an extension module that would pull each stores accordingly for each report settings. Then, to build an event whenever a specific action in the back-end must apply. This way, it would avoid on playing with user group permissions as to automatically update the arrays as you intend rather than playing with core files.

Re: Settings not persistent?

Posted: Mon Jun 15, 2020 10:45 am
by letxobnav
As soon as I hit the save button, the specific keys (report_product_purchased_myown) are removed from the oc_setting table and the report is disabled. No way I can enable it again, unless I recreate the keys (status & sort_order) manually in the oc_setting table. Can't be right.... right?
When using the official functions for manipulating settings, the particular old settings are first deleted and then the new are added.
So check if you are using the correct functions correctly.
OC uses the delete&add vs update scheme very often and in many cases it is a very dangerous method.

Re: Settings not persistent?

Posted: Thu Jun 18, 2020 4:46 am
by LDeeJay
Thanks all, that solved it.
I found a site that explains the procedure properly (albeit for modules, not reports) and took it from there. It appeared that my controller was missing the install-function (?!). And thus when activating, uninstalling and not installing. Weird because it's a copy of an existing report. Oh well... it's solved now.
Cheers,
Leon