GithubHelp home page GithubHelp logo

laravel-akeneo's Introduction

โš ๏ธ Abandoned: This package is abandoned, we have developed a new client.

Akeneo wrapper for Laravel

Latest Version on Packagist GitHub Code Quality Action Status GitHub Code Style Action Status Total Downloads

This package allows you to work with Akeneo in a more Laravel like way.

Requirements

  • PHP 8 or above
  • Akeneo installation

Installation

You can install the package via composer:

composer require justbetter/laravel-akeneo

Configuration

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,
];

Usage

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

How to use

All

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

Lazy

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

Find a resource by its code

$product = Product::find('code-123');

Attributes

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

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

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

Testing

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

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

laravel-akeneo's People

Contributors

quintenbuis avatar ramonrietdijk avatar stylecibot avatar vincentbean avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.