(This is not actually published yet, as it is in pre-alpha. I do not follow semantic versioning, so use at your own risk)
composer require andrewtweber/laravel-etsy
To publish the config and migrations, run:
php artisan vendor:publish --provider="Etsy\EtsyServiceProvider"
Add the EtsyUserInterface
interface and EtsyUser
trait to your User
class.
use Etsy\EtsyUser;
use Etsy\EtsyUserInterface;
class User extends Model implements EtsyUserInterface
{
use EtsyUser;
}
Go to your Etsy developer account to get your API keys and
add them to your .env
ETSY_API_KEY=
ETSY_API_SECRET=
Add the commands to your console Kernel.
protected $commands = [
\Etsy\Console\Commands\EtsyTaxonomies::class,
\Etsy\Console\Commands\EtsyUpdateListings::class,
];
protected function schedule(Schedule $schedule)
{
// Recommend running this daily to sync shops and items
$schedule->command('etsy:shops')->dailyAt('06:00');
}
This command probably only needs to be run once, or very rarely:
php artisan etsy:taxonomy
This will fetch all of Etsy's taxonomies which can then be mapped to your own custom categories.
If you need to extend any of the Etsy models or pivots, you can do so and update the configuration to point to your model class.
Sample model:
namespace App\Models;
class Shop extends \Etsy\Models\Shop implements HasCommentsInterface
{
use HasComments;
}
Config:
return [
'models' => [
'shop' => \App\Models\Shop::class,
],
];
ShopItemPhotoFetched
- when a new item is synced, this event gets dispatched which contains the
shop item, the full URL to the image, and Etsy's external ID for that image. You can process this
(save it to storage, etc) by listening for this event.
- Make sure to add some policies for the
Shop
andShopItem
classes. - Some sample Nova models are supplied, copy them into your
app/Nova
folder.
- Not sure if the observers can be registered in the package service provider, especially if the model classes are overridden.