laravel-shopify
laravel-shopify copied to clipboard
Event to notify Successful App Installation on the Store.
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,
],
];
}
Cant you just do this with an AfterAuthentication Job? Thats how I do this today.
@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.