Normally with VQMod clients would simply overwrite the files and stored data wouldn’t be affected.
But now the extension is installed through the extension installer and the only way to install the same extension again is to remove it first which will remove all data/settings from the database.
How can clients update an extension which is installed through the extension installer without losing data?
All my extensions: Click here or Click here
OC version. As for updating extensions without loosing data, there are no guarantee from any extension distributions that may present to the buyers.Reptile wrote: ↑Sat May 06, 2023 2:19 pmI just finished my first event driven extension and was wondering how I can update this if I release a new version?
Normally with VQMod clients would simply overwrite the files and stored data wouldn’t be affected.
But now the extension is installed through the extension installer and the only way to install the same extension again is to remove it first which will remove all data/settings from the database.
How can clients update an extension which is installed through the extension installer without losing data?
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
I'm adding an update to the index function, in the admin. If the add-on is old for some reason, then I start the automatic update and display a message about the successful update, if it's new, then I skip the step.
My FREE extensions in marketplace. [ security | flexibility | speedup ]
As from now my extension is installed through the extension installer and show there with a version number let's say version 1.0.
Now if I update my extension and make a version 1.1 you can't install this through the extension installer as you get a error "Extension already installed"
So if I want to install the new version I need to uninstall the module first and then remove the extension in the extension installer.
By doing so all saved settings will be removed from the database.
Now that I am writing this message I got an idea.
I could build in an export/import settings button so users can export their settings before uninstalling the module.
And import them again after installing the new version.
But this is extra work for the client which I preferably don't want.
How do you guys do this in your extensions?
All my extensions: Click here or Click here
The OC version still hasn't been posted. By building an API, this can be accomplished. There are lots of extensions on the Marketplace that can accomplish update automations already. I would suggest to take a look.Reptile wrote: ↑Sun May 07, 2023 5:21 pmI don't think you guys understand my question.
As from now my extension is installed through the extension installer and show there with a version number let's say version 1.0.
Now if I update my extension and make a version 1.1 you can't install this through the extension installer as you get a error "Extension already installed"
So if I want to install the new version I need to uninstall the module first and then remove the extension in the extension installer.
By doing so all saved settings will be removed from the database.
Now that I am writing this message I got an idea.
I could build in an export/import settings button so users can export their settings before uninstalling the module.
And import them again after installing the new version.
But this is extra work for the client which I preferably don't want.
How do you guys do this in your extensions?
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
straightlight wrote: ↑Sun May 07, 2023 9:03 pmThe OC version still hasn't been posted. By building an API, this can be accomplished. There are lots of extensions on the Marketplace that can accomplish update automations already. I would suggest to take a look.Reptile wrote: ↑Sun May 07, 2023 5:21 pmI don't think you guys understand my question.
As from now my extension is installed through the extension installer and show there with a version number let's say version 1.0.
Now if I update my extension and make a version 1.1 you can't install this through the extension installer as you get a error "Extension already installed"
So if I want to install the new version I need to uninstall the module first and then remove the extension in the extension installer.
By doing so all saved settings will be removed from the database.
Now that I am writing this message I got an idea.
I could build in an export/import settings button so users can export their settings before uninstalling the module.
And import them again after installing the new version.
But this is extra work for the client which I preferably don't want.
How do you guys do this in your extensions?
What do you mean by the oc version hasn’t been posted?
I’m posting in the Opencart 4 forum so I am talking about 4.x
All my extensions: Click here or Click here
Each versions are different, even by features. Forum rules.Reptile wrote: ↑Sun May 07, 2023 10:54 pmstraightlight wrote: ↑Sun May 07, 2023 9:03 pmThe OC version still hasn't been posted. By building an API, this can be accomplished. There are lots of extensions on the Marketplace that can accomplish update automations already. I would suggest to take a look.Reptile wrote: ↑Sun May 07, 2023 5:21 pmI don't think you guys understand my question.
As from now my extension is installed through the extension installer and show there with a version number let's say version 1.0.
Now if I update my extension and make a version 1.1 you can't install this through the extension installer as you get a error "Extension already installed"
So if I want to install the new version I need to uninstall the module first and then remove the extension in the extension installer.
By doing so all saved settings will be removed from the database.
Now that I am writing this message I got an idea.
I could build in an export/import settings button so users can export their settings before uninstalling the module.
And import them again after installing the new version.
But this is extra work for the client which I preferably don't want.
How do you guys do this in your extensions?
What do you mean by the oc version hasn’t been posted?
I’m posting in the Opencart 4 forum so I am talking about 4.x
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Ok 4.0.2.1 thenstraightlight wrote: ↑Sun May 07, 2023 11:35 pmEach versions are different, even by features. Forum rules.Reptile wrote: ↑Sun May 07, 2023 10:54 pmstraightlight wrote: ↑Sun May 07, 2023 9:03 pm
The OC version still hasn't been posted. By building an API, this can be accomplished. There are lots of extensions on the Marketplace that can accomplish update automations already. I would suggest to take a look.
What do you mean by the oc version hasn’t been posted?
I’m posting in the Opencart 4 forum so I am talking about 4.x

All my extensions: Click here or Click here
Still, at this time, it has been suggested many times by forum supporters that OC v4.x releases not to use it until a stable version gets released.Reptile wrote: ↑Mon May 08, 2023 12:04 amOk 4.0.2.1 thenstraightlight wrote: ↑Sun May 07, 2023 11:35 pmEach versions are different, even by features. Forum rules.![]()
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
I understand that.straightlight wrote: ↑Mon May 08, 2023 12:10 amStill, at this time, it has been suggested many times by forum supporters that OC v4.x releases not to use it until a stable version gets released.Reptile wrote: ↑Mon May 08, 2023 12:04 amOk 4.0.2.1 thenstraightlight wrote: ↑Sun May 07, 2023 11:35 pm
Each versions are different, even by features. Forum rules.![]()
But it is good to convert atleast one extension just to see how much work it is and what issues you might experience.
And this is the only question I still have after converting my extension.
How should a client install a new version of my extension without losing all previous set settings in the extension?
All my extensions: Click here or Click here
IMHO the current way OpenCart 4 implements the installation of extensions is poorly implemented. This is just one of many issues which need to be addressed.
In general the extensions feature should at least address below issues:
- Have the extension name in the install.json, so developer can use any filename for his extension
- Use proper namespaces for extensions, reflecting the underlying folder structure
- Simplify the uninstall, it should remove all of its files from its extension folder
- Upgrade functionality from older to newer extension version without loosing existing data
- Better ways to override or modify core functions beyond event handlers, especially for library files
I am thinking about writing up a plugin manager for OpenCart 4, have already addressed the namespace issue.
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
This answer was very helpful.JNeuhoff wrote: ↑Mon May 08, 2023 5:46 pmUnfortunately there is no built-in way in OpenCart 4 (that I know of) to upgrade an existing extension without loosing all its data.
IMHO the current way OpenCart 4 implements the installation of extensions is poorly implemented. This is just one of many issues which need to be addressed.
In general the extensions feature should at least address below issues:
There might be other issues, too. Please share them with us here on this forum.
- Have the extension name in the install.json, so developer can use any filename for his extension
- Use proper namespaces for extensions, reflecting the underlying folder structure
- Simplify the uninstall, it should remove all of its files from its extension folder
- Upgrade functionality from older to newer extension version without loosing existing data
- Better ways to override or modify core functions beyond event handlers, especially for library files
I am thinking about writing up a plugin manager for OpenCart 4, have already addressed the namespace issue.
I couldn’t agree more.
So I was right about no possibility to upgrade your extension without losing data.
You have some good points.
I hope they will fix some of these issues in the following releases.
All my extensions: Click here or Click here
Look at the file admin/controller/extension/module.php (Opencart 4.0.0.0) :
function install() , Line ~ 126:
Code: Select all
// Call install method if it exists
$this->load->controller('extension/' . $extension . '/module/' . $code . '|install');
Code: Select all
// Call uninstall method if it exists
$this->load->controller('extension/' . $this->request->get['extension'] . '/module/' . $this->request->get['code'] . '|uninstall');
Our new Opencart Extension:
AI Assistant - automatic product and category text generator
Thanks for the tip!frank79 wrote: ↑Tue May 09, 2023 5:06 pmHi Reptile, in your case the easiest way would be to write a couple of small functions in your plugin(s), called install() and uninstall(), they must be placed in the (admin) controller of your extension. Opencart calls them automatically when you install/uninstall your extension, you don't have to add any feature like buttons or anything like that to manually export the settings.
Look at the file admin/controller/extension/module.php (Opencart 4.0.0.0) :
function install() , Line ~ 126:
function uninstall(), Line ~ 180:Code: Select all
// Call install method if it exists $this->load->controller('extension/' . $extension . '/module/' . $code . '|install');
The function uninstall() on your plugin saves settings in a sql file and store it somewhere on the server (system/storage/blabla for example, if you have many plugins create a nice folder structure where you can organize saved data). The function install() will check if there is any sql backup, if yes, restores it.Code: Select all
// Call uninstall method if it exists $this->load->controller('extension/' . $this->request->get['extension'] . '/module/' . $this->request->get['code'] . '|uninstall');
The install and uninstall functions are already used to register and remove the events.
I just finished playing around with the import/ export buttons and this works.
But your idea is better.
I will remove these buttons and save the settings file on the server.
Then when installing check if there is a file present and restore this.
All my extensions: Click here or Click here
Even if I try to get all settings in the first line of the method I get an empty array.
So the module settings are cleared before I can get them.
So I added the logic of saving the settings in the Save method instead.
And this works fine.
Each time you save the settings they are also written to a file in the storage folder.
And if you install a new version of the extension I check for this file in the Install method and restore the settings.
All my extensions: Click here or Click here
If you could edit the title to include [SOLVED] that would be great.
DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.
https://www.youtube.com/watch?v=zXIxDoCRc84
Users browsing this forum: No registered users and 1 guest