laravel-shopify icon indicating copy to clipboard operation
laravel-shopify copied to clipboard

Event to notify Successful App Installation on the Store.

Open abishekrsrikaanth opened this issue 3 years ago • 1 comments

The AppInstalled event will be triggered after the installation of App on the store. This can be used to run jobs after successful installation. For example, fetching data from the store that is needed by the application.

Here is an example of how to set up a Listener and subscribe to it on the project's EventServiceProvider.


<?php

namespace App\Listeners;

use Osiset\ShopifyApp\Messaging\Events\AppInstalled;

class AppInstalledEventListener
{
    /**
     * Handle AppInstalled Event.
     *
     * @param  Osiset\ShopifyApp\Messaging\Events\AppInstalled $event
     * @return void
     */
    public function handle(AppInstalled $event)
    {
            $shop = $event->getShop();
            // Get Shop Details
            // Get Products
            // Get Collections
            // etc...
    }
}

Once your listener has been defined, you may register it within your application's EventServiceProvider:

<?php

namespace App\Providers;

use App\Listeners\AppInstalledEventListener;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Osiset\ShopifyApp\Messaging\Events\AppInstalled;

class EventServiceProvider extends ServiceProvider
{
    protected $listen = [
        AppInstalled::class => [
            AppInstalledEventListener::class,
        ],
    ];
}

abishekrsrikaanth avatar Jan 12 '22 20:01 abishekrsrikaanth

Cant you just do this with an AfterAuthentication Job? Thats how I do this today.

talktohenryj avatar Aug 02 '22 19:08 talktohenryj

@osiset I'm going to close this in favor of keeping the AppInstalledJob and there's a lot of other code changed in here we've already merged in.

Kyon147 avatar Sep 10 '22 07:09 Kyon147