Skip to content

01 Install

Lorenzo Ruozzi edited this page Aug 29, 2022 · 1 revision

Requirements

  • PHP ^8.0
  • Sylius ^1.11
  • Akeneo PIM CE or EE >= 3.2. The requirement for the version 3.2 is because the provided implementation of the product importer relies on the family_variant key in the Akeneo GET Product model API response.

Installation

  1. Run composer require webgriffe/sylius-akeneo-plugin.

  2. Add the plugin to the config/bundles.php file:

    Webgriffe\SyliusAkeneoPlugin\WebgriffeSyliusAkeneoPlugin::class => ['all' => true],
  3. Import the plugin config by creating a file in config/packages/webgriffe_sylius_akeneo_plugin.yaml with the following contents:

    imports:
      - { resource: "@WebgriffeSyliusAkeneoPlugin/Resources/config/config.yaml" }
  4. Import the plugin routes by creating a file in config/routes/webgriffe_sylius_akeneo_plugin.yaml with the follwing content:

    webgriffe_sylius_akeneo_plugin_admin:
        resource: "@WebgriffeSyliusAkeneoPlugin/Resources/config/admin_routing.yaml"
        prefix: /admin
  5. Finish the installation by updating the database schema and installing assets:

    bin/console doctrine:migrations:diff
    bin/console doctrine:migrations:migrate
    bin/console assets:install
    bin/console sylius:theme:assets:install
  6. Optional. If you want you can also add the Schedule Akeneo PIM import button in the product's detail and edit page. Override Sylius template by create a new file in the folder: templates/bundles/SyliusAdminBundle/Product/_showInShopButton.html.twig. Copy the content from the original Sylius file and paste it in the new file. Finally, add the button to the bottom of the file.

     # ...
    
     <a class="ui labeled icon button violet" href="{{  path('webgriffe_sylius_akeneo_product_enqueue', {'productId': product.id }) }}" >  
       <i class="icon cloud download"></i>  
       {{ 'webgriffe_sylius_akeneo.ui.enqueue'|trans }}  
     </a>
    
  7. Optional (usually only on production or pre-production environments). Install the suggested crontab.

Configuration

First of all you must configure your Akeneo API connection parameters. Edit the config/packages/webgriffe_sylius_akeneo_plugin.yaml file by adding the following content:

# ...

webgriffe_sylius_akeneo:
  api_client:
    # These values are from the official Akeneo PIM demo, replace with yours.
    base_url: 'http://demo.akeneo.com/'
    username: 'admin'
    password: 'admin'
    client_id: '1_demo_client_id'
    secret: 'demo_secret'

Pay attention that among these parameters there are some sensitive configuration that you probably don't want to commit in your VCS. There are different solutions to this problem, like env configurations and secrets. Refer to Symfony best practices doc for more info.

Clone this wiki locally