poel Posted January 13, 2019 Share Posted January 13, 2019 Hi, I'm working on a custom module on PrestaShop. My goal is to update the module in order to set the permissions for a web service created during installation. I succeeded in my purpose this way: public function install() { $keyId = $this->getKeyId(); $wsKey = new WebserviceKey($keyId ? $keyId : null); $wsKey->active = true; $wsKey->description = self::KEY_DESCRIPTION_MARKER; do { $wsKey->key = $this->generateKey(self::KEY_LENGTH); } while (WebserviceKey::keyExists($wsKey->key)); $wsKey->add(); $permissions_file = "../modules/".$this->name."/data/permissions.json"; $jsonPermissions = file_get_contents($permissions_file); //TODO controlli sul file $permissions_to_set = json_decode($jsonPermissions,true); $wsKey->setPermissionForAccount($wsKey->id,$permissions_to_set); $configuration = new stdClass(); $configuration->soap_key = $wsKey->key; return parent::install() && $this->registerHook('actionAdminControllerSetMedia') && $this->registerHook('displayBackOfficeHeader'); } in this way during the installation of the module, I set the permissions in the correct way, taking them from the JSON file present in data/permissions.json this is ok for the new installations, but if I have to update an already installed module, how can I do? I tried this way: function upgrade_module_2_1_4($module, $install = true) { return true; } thinking that by passing install = true the module would re-run the install function, but PrestaShop seems to update the module, but does not update the permissions as indicated in the function to update Link to comment Share on other sites More sharing options...
noah ming Posted January 30, 2020 Share Posted January 30, 2020 got the same problem Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now