Skip to content
This repository has been archived by the owner on May 11, 2023. It is now read-only.

Error when re-installing the plugin #14

Closed
TobiasGraml11 opened this issue Aug 5, 2022 · 6 comments
Closed

Error when re-installing the plugin #14

TobiasGraml11 opened this issue Aug 5, 2022 · 6 comments

Comments

@TobiasGraml11
Copy link

The registration process has no check for an existing database entry. After uninstalling the app, this error is shown when trying to install:

image

@DannyDan
Copy link

DannyDan commented Aug 7, 2022

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();

}

@TobiasGraml11
Copy link
Author

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?

@DannyDan
Copy link

DannyDan commented Aug 8, 2022

Sure, I am using a webhook:

The function should already be included in AppLifecycleEventController.php

@TobiasGraml11
Copy link
Author

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!

flkasper pushed a commit to flkasper/bal-shopware-AppTemplate that referenced this issue Sep 6, 2022
- add null as a possible return type in ShopRepositoryInterface
- adjust implementation of ShopRepository to return null if shop by id does not exist
- adjust RegistrationService to call create shop in db only if not exist yet
@flkasper
Copy link
Contributor

flkasper commented Sep 7, 2022

I created a (small) fix for the problem in the start post. Pull request in shopware/app-bundle-symfony#27 and #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.

@flkasper
Copy link
Contributor

flkasper commented Sep 7, 2022

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.

Christian-Rades added a commit that referenced this issue Mar 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants