Closed TobiasGraml11 closed 1 year ago
I am using this code to remove the entry when the App is deleted:
public function appDeleted(SymfonyRequest $request): Response { $queries = json_decode($request->getContent(), true); $shop = $this->shopRepository->getShopFromId($queries['source']['shopId']);
$this->shopRepository->deleteShop($shop);
return new Response();
}
I am using this code to remove the entry when the App is deleted:
public function appDeleted(SymfonyRequest $request): Response { $queries = json_decode($request->getContent(), true); $shop = $this->shopRepository->getShopFromId($queries['source']['shopId']);
$this->shopRepository->deleteShop($shop); return new Response();
}
Thanks for the code. May I ask, how you get this function called? Are you listening to the webhook or is there some endpoint called once it's deleted?
Sure, I am using a webhook:
The function should already be included in AppLifecycleEventController.php
Sure, I am using a webhook:
The function should already be included in AppLifecycleEventController.php
Just checked the archived app example, I guess you mean this? https://github.com/shopwareLabs/AppExample/blob/master/src/SwagAppsystem/Controller/AppLifecycleEventController.php Thanks for the information!
I created a (small) fix for the problem in the start post. Pull request in https://github.com/shopware/AppBundle/pull/27 and https://github.com/shopware/AppTemplate/pull/16
During the registration process, it checks whether the store already exists. If it does not exist yet, the store will be created in the database.
It would probably make sense if there would also be an automatic deregistration, similar to the registration, without having to configure the app.deleted webhook yourself in your app manifest.xml and evaluate it on the server side. For this, however, the Shopware core would also have to be adapted.
ps: I am currently working on an AppLifecycle bundle for our app server. The bundle registers a controller that then triggers lifecycle events from it via the event dispatcher. These can then be used by subscribers on the actual server, for example, to delete the app or, as in our case, for statistics.
You can find the current code in the dev branch of repo bitsandlikes-shopware/app-lifecycle-bundle.
The registration process has no check for an existing database entry. After uninstalling the app, this error is shown when trying to install: