โ ๏ธ Abandoned: This package is abandoned, we have developed a new client.
This package allows you to work with Akeneo in a more Laravel like way.
- PHP 8 or above
- Akeneo installation
You can install the package via composer:
composer require justbetter/laravel-akeneo
Add the following values to your .env
file:
AKENEO_URL=
AKENEO_CLIENT_ID=
AKENEO_SECRET=
AKENEO_USERNAME=
AKENEO_PASSWORD=
You can optionally publish the config file with:
php artisan vendor:publish --provider="JustBetter\Akeneo\AkeneoServiceProvider" --tag="akeneo-config"
This is the contents of the published config file:
return [
'models' => [
'product_model' => \JustBetter\Akeneo\Models\ProductModel::class,
'product' => \JustBetter\Akeneo\Models\Product::class,
'attribute' => \JustBetter\Akeneo\Models\Attribute::class,
'channel' => \JustBetter\Akeneo\Models\Channel::class,
'attribute_types' => [
'Simpleselect' => \JustBetter\Akeneo\Models\Attribute\Simpleselect::class,
'Multiselect' => \JustBetter\Akeneo\Models\Attribute\Multiselect::class,
'Text' => \JustBetter\Akeneo\Models\Attribute\Text::class,
'Date' => \JustBetter\Akeneo\Models\Attribute\Date::class,
],
],
'connections' => [
'default' => [
'url' => env('AKENEO_URL'),
'client_id' => env('AKENEO_CLIENT_ID'),
'secret' => env('AKENEO_SECRET'),
'username' => env('AKENEO_USERNAME'),
'password' => env('AKENEO_PASSWORD'),
],
],
'cache_ttl' => 30,
];
supported features:
- Multiple Akeneo connections (WIP)
- Custom model classes
- Product Models
- Get all
- Get all lazily
- Find by code
- Save
- Products
- Get all
- Get all lazily
- Find by code
- Save
Get all of the resources from Akeneo
$models = ProductModel::all();
This will return a Collection
by default but can be modified
by overwriting the newCollection
method on your custom model.
The all()
method can also be cached by setting the TTL in the config
Getting all of the resources lazily from Akeneo returns a LazyCollection
$models = ProductModel::lazy();
See the laravel docs on lazy collections for a full list of methods
Find a resource by its code
$product = Product::find('code-123');
Calling an attribute code on a model will return a class of that attributes type. These are defined in the config and can be extended easily.
$product->product_name->setValue(
data: 'test product 3',
locale: null, # default
scope: null # default
);
Options can be constructed and passed to attributes compatible with them
$option = \JustBetter\Akeneo\DataObjects\Option::make(
data: 'tag 1',
locale: null,
scope: null
)
$product->tags->addOption($option);
$product->tags->removeOption($option);
$product->tags->syncOptions([$option1, $option2]);
Save an altered model and persist it to akeneo
$product = Product::find('code-123');
$product->product_name->setValue(
data: 'test product 3',
locale: null, # default
scope: null # default
);
$product->save();
The workflow requires 99%
of the package to be tested.
make test
# -- OR --
make coverage
Make sure to also run static analysis checks
make analysis
Or combine the 2 requirements
make all
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.