synolia/sylius-akeneo-plugin

Akeneo connector for Sylius.

Installs: 65 982

Dependents: 0

Suggesters: 0

Security: 0

Stars: 21

Watchers: 13

Forks: 21

Open Issues: 6

Type:sylius-plugin

v3.4.0 2023-10-17 08:31 UTC

README

License CI - Analysis CI - Sylius Version Total Downloads

68747470733a2f2f64656d6f2e73796c6975732e636f6d2f6173736574732f73686f702f696d672f6c6f676f2e706e67

Sylius Akeneo Plugin

68747470733a2f2f73796c6975732e636f6d2f6173736574732f62616467652d617070726f7665642d62792d73796c6975732e706e67

This plugin allow you to import data from Akeneo PIM.

Features

Requirements

Version
PHP ^8.0
Sylius ^1.10
Akeneo PIM >=v6.0

Installation

  1. Add the bundle and dependencies in your composer.json :

    composer require synolia/sylius-akeneo-plugin --no-scripts
  2. Enable the plugin in your config/bundles.php file by add

    Synolia\SyliusAkeneoPlugin\SynoliaSyliusAkeneoPlugin::class => ['all' => true],
  3. Import required config in your config/packages/_sylius.yaml file:

    imports:
        - { resource: "@SynoliaSyliusAkeneoPlugin/Resources/config/config.yaml" }
  4. Import routing in your config/routes.yaml file:

    synolia_akeneo:
        resource: "@SynoliaSyliusAkeneoPlugin/Resources/config/routes.yaml"
        prefix: '/%sylius_admin.path_name%'
  5. Add Asset trait to Product.php and ProductVariant.php entities and add TaxonAttributes trait to Taxon entity

    <?php
    
    declare(strict_types=1);
    
    namespace App\Entity\Product;
    
    use App\Entity\Product\ProductTranslation;
    use Doctrine\ORM\Mapping as ORM;
    use Sylius\Component\Core\Model\Product as BaseProduct;
    use Sylius\Component\Product\Model\ProductTranslationInterface;
    use Synolia\SyliusAkeneoPlugin\Entity\ProductAssetTrait;
    
    /**
     * @ORM\Entity
     * @ORM\Table(name="sylius_product")
     */
    #[ORM\Entity]
    #[ORM\Table(name: 'sylius_product')]
    class Product extends BaseProduct
    {
        use ProductAssetTrait {
            __construct as private initializeAssetsCollection;
        }
    
        public function __construct()
        {
            parent::__construct();
            $this->initializeAssetsCollection();
        }
    
        protected function createTranslation(): ProductTranslationInterface
        {
            return new ProductTranslation();
        }
    }
    <?php
    
    declare(strict_types=1);
    
    namespace App\Entity\Product;
    
    use Doctrine\ORM\Mapping as ORM;
    use Sylius\Component\Core\Model\ProductVariant as BaseProductVariant;
    use Sylius\Component\Product\Model\ProductVariantTranslationInterface;
    use Synolia\SyliusAkeneoPlugin\Entity\ProductVariantAssetTrait;
    
    /**
     * @ORM\Entity
     * @ORM\Table(name="sylius_product_variant")
     */
    #[ORM\Entity]
    #[ORM\Table(name: 'sylius_product_variant')]
    class ProductVariant extends BaseProductVariant
    {
        use ProductVariantAssetTrait {
            ProductVariantAssetTrait::__construct as private initializeAssetsCollection;
        }
    
        public function __construct()
        {
            parent::__construct();
    
            $this->initializeAssetsCollection();
        }
    
        protected function createTranslation(): ProductVariantTranslationInterface
        {
            return new ProductVariantTranslation();
        }
    }
    <?php
    
    declare(strict_types=1);
    
    namespace App\Entity\Taxonomy;
    
    use Doctrine\ORM\Mapping as ORM;
    use Sylius\Component\Core\Model\Taxon as BaseTaxon;
    use Sylius\Component\Taxonomy\Model\TaxonTranslationInterface;
    use Synolia\SyliusAkeneoPlugin\Component\TaxonAttribute\Model\TaxonAttributeSubjectInterface;
    use Synolia\SyliusAkeneoPlugin\Entity\TaxonAttributesTrait;
    
    /**
     * @ORM\Entity
     * @ORM\Table(name="sylius_taxon")
     */
    #[ORM\Entity]
    #[ORM\Table(name: 'sylius_taxon')]
    class Taxon extends BaseTaxon implements TaxonAttributeSubjectInterface
    {
        use TaxonAttributesTrait {
            __construct as private initializeTaxonAttributes;
        }
    
        public function __construct()
        {
            parent::__construct();
    
            $this->createTranslation();
            $this->initializeTaxonAttributes();
        }
    
        protected function createTranslation(): TaxonTranslationInterface
        {
            return new TaxonTranslation();
        }
    }
  6. Apply plugin migrations to your database:

    bin/console doctrine:migrations:migrate
  7. Clear cache

    bin/console cache:clear

Development

Akeneo Enterprise Edition

Reference Entity and Asset attribute types

License

This library is under the EUPL-1.2 license.

Credits

Developed by Synolia.