Akeneo

Container Setup

Akeneo has some reasonably complex requirements.

See https://docs.akeneo.com/2.0/install_pim/manual/system_requirements/system_requirements.html

Here is how to set up an Akeneo container:

Run the Standard Create Staging Container Script

1
2
3
ssh cluster1
cd /opt/Projects/snippets-edmondscommerce/Cluster/shellscripts/cluster/
bash setupPublicFacingContainers/setupStagingContainer/createGenericContainer.bash [CLIENTNAME] akeneo 71

Remove and Reinstall MySQL to upgrade to 5.7

1
2
3
4
5
6
sshContainer clientname-akeneo
sudo bash
yum -y remove Percona*
bash /home/ec/mysqlInstall/installMysql.bash 57
mysql_upgrade --force
systemctl restart mysql

Adjust PHP Configuration

Some standard PHP configuration should probably be changed:

Upload Limits

I'd suggest allowing huge file uploads, so you need to edit /etc/php.ini and for the following, find and update the values:

1
2
post_max_size = 200M
upload_max_filesize = 200M

Install PHP Dependencies

There are some other things required:

APCu

1
yum -y install php71w-pecl-apcu

ImageMagick

1
yum -y install php71w-pecl-imagick

Install ElasticSearch

Akeneo uses ElasticSearch, so we need to install this

Java

1
yum install java-1.8.0-openjdk

Elastic Search 5.6

1
2
3
4
5
6
cd ~
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.4.rpm
rpm -ivh elasticsearch-5.6.4.rpm
systemctl daemon-reload
systemctl enable elasticsearch
systemctl start elasticsearch

Javascript Stuff

Various Javascript things are required:

NodeJS

First we need Node

1
2
curl -sL https://rpm.nodesource.com/setup_7.x | bash -
yum install -y nodejs

Yarn

Package manager is Yarn

1
2
wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo
yum -y install yarn

Now Actually Install Akeneo

So now we have all the dependencies in place, we can actually install it

Nginx

Setup the Nginx config with something like:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
server {
    listen       80;
    listen       443 ssl http2;
    server_name www.akeneo.CLIENTNAME.desktop.com;
    ssl_certificate      /etc/ssl/nginx/www.akeneo.CLIENTNAME.desktop.com.crt;
    ssl_certificate_key  /etc/ssl/nginx/www.akeneo.CLIENTNAME.desktop.com.key;
    server_tokens off;

    include includes/header.conf;

    include includes/gzip.conf;

    keepalive_timeout 0;

    root /var/www/vhosts/akeneo/web;

    location / {
        try_files $uri /app_dev.php$is_args$args; 
    }

    include includes/php-fpm.conf;

    access_log /var/log/nginx/akeneo.CLIENTNAME.desktop.co.uk.access.log main;
    error_log /var/log/nginx/akeneo.CLIENTNAME.desktop.co.uk.error.log info;
}

Create Database

You need to create a database to install Akeneo into. Something along the lines of:

1
2
mysql -e "CREATE DATABASE akeneo_pim"
mysql -e "GRANT ALL PRIVILEGES ON akeneo_pim.* TO akeneo_pim@localhost IDENTIFIED BY 'akeneo_pim';"

Setup Params

Need to set up the params file. Something along the lines of:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
parameters:
    database_driver: pdo_mysql
    database_host: localhost
    database_port: null
    database_name: akeneo_pim
    database_user: akeneo_pim
    database_password: akeneo_pim
    locale: en
    secret: ___changeme___
    product_index_name: akeneo_pim_product
    product_model_index_name: akeneo_pim_product_model
    product_and_product_model_index_name: akeneo_pim_product_and_product_model
    index_hosts: 'localhost: 9200'
    installer_data: 'PimInstallerBundle:minimal'

Note

The last line is important, otherwise Akeneo will install sample data which you generally don't want

Create Project

Now to use composer to create the project:

1
2
3
4
5
cd /var/www/vhosts
composer create-project --prefer-dist akeneo/pim-community-standard ./akeneo
cd akeneo
chmod u+x bin/console
bin/console pim:install

Post Install Tasks

Various other things need to be done

1
2
3
cd /var/www/vhosts/akeneo
yarn install
yarn run webpack

Cron Jobs

Need to schedule a few cron jobs

1
2
*/15 *  *    *    *    php /var/www/vhosts/akeneo/bin/console pim:completeness:calculate --env=prod > /var/www/vhosts/akeneo/app/logs/calculate_completeness.log 2>&1
*/15 *  *    *    *    php /var/www/vhosts/akeneo/bin/console pim:versioning:refresh --env=prod > /var/www/vhosts/akeneo/app/logs/refresh_versioning.log 2>&1

Job Queue

There is also a job queue. For development I suggest you do not set up the job queue, but you will need to for production.

For development, run jobs manually by running:

1
2
cd /var/www/vhosts/akeneo
bin/console akeneo:batch:job-queue-consumer-daemon --env=prod --run-once

Logging In

Once the installation has completed then you should be able to access Akeneo and log in

The default username and password are admin and admin.

Warning

These are really crap and need to be changed. The admin user should be dropped and a new less obvious user created with a strong password.

Developing on Akeneo

PHPStorm

The first thing we need to do is get PHPStorm nicely set up.

You need to install the Symfony plugin which will automatically suggest installing the annotations plugin as well.

Next you can create the Akeneo project in PHPStorm

You should get notified that Symfony has been detected and that PHPStorm can auto configure - agree to this

Next you get notified about composer.json being detected and possibly auto conigured. Agree to this as well.

Once you do the above, then you should now have a much nicer time, with things like yaml config files that describe services being auto linked (hit [ctrl] + left click)

Getting the PIM DOCs and Example Code

You might find it useful to bring in the documentation repo into your project so that you can look at example code in PHPStorm, search it more easily etc.

To do this you need to adjust your main composer.json file

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{
  "require-dev": {
    "doctrine/migrations": "1.5.0",
    "doctrine/doctrine-migrations-bundle": "1.2.1",
    "akeneo/pim-docs": "dev-master"
  },
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/akeneo/pim-community-dev.git",
      "branch": "master"
    },
    {
      "type": "package",
      "package": {
        "name": "akeneo/pim-docs",
        "version": "master",
        "source": {
          "url": "https://github.com/akeneo/pim-docs.git",
          "type": "git",
          "reference": "master"
        }
      }
    }
  ],
}

Note

This is really useful and makes understanding the docs a lot easier. I also think the raw rst files are easier to read

Reinstalling the Database

If you want to start over, you can do this easily by running the following:

1
2
bin/console cache:clear --env=prod
bin/console pim:install --force --symlink --clean --env=prod

Overriding Services

If you find a core component that you want to override then, thanks to the Symfony DI, this is quite easy.

Firstly, create your class. You might choose to extend the class you want to override and then override or add methods as required.

Then to configure the DI container to use your class in place of the standard one, you can copy and paste the service definition into your own bundle Resource/config/filename.yml

For example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
    #Overriding
    pim_catalog.updater.setter.media_value:
      class: \EdmondsCommerce\Bundle\OscommerceConnectorBundle\File\MediaAttributeSetterOverride
      parent: pim_catalog.updater.setter.abstract
      arguments:
          - '@akeneo_file_storage.file_storage.file.file_storer'
          - '@akeneo_file_storage.repository.file_info'
          - ['pim_catalog_file', 'pim_catalog_image']
      tags:
          - { name: 'pim_catalog.updater.setter' }

To confirm this has worked, you can then run

1
bin/console debug:container [search term]

Which gives you information like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
Information for Service "pim_catalog.updater.setter.media_value"
================================================================

 ---------------- ------------------------------------------------------------------------------------
  Option           Value
 ---------------- ------------------------------------------------------------------------------------
  Service ID       pim_catalog.updater.setter.media_value
  Class            EdmondsCommerce\Bundle\OscommerceConnectorBundle\File\MediaAttributeSetterOverride
  Tags             pim_catalog.updater.setter
  Public           no
  Synthetic        no
  Lazy             no
  Shared           yes
  Abstract         no
  Autowired        no
  Autoconfigured   no
 ---------------- ------------------------------------------------------------------------------------

Setting Up Locale

If you want to use en_GB as a locale and GBP as a currency, then that needs to be configured because it all defaults to en_US

Enable Currency

To enable the currency, you need to go to Settings->Currencies, find your currency and then toggle enable it

Changing Default Locale and Currency

You have to do this by editing the default Channel. So in the admin, go to Settings->Channel - edit the Default channel and then set the currency and locale accordingly. You will need to have previously enabled your chosen currency for this to work.

Trouble Shooting

Your first port of call for debugging issues should be to look at the logs.

1
tail var/log/*.log

If you are in dev mode then the Symfony web debug toolbar is a fantastic tool which gives a lot of information, but unfortunately it's quite easy to break things to the point that the toolbar won't load.

Memory Issues

You can hit memory issues if you run a console command without the --env=prod flag

Danger

The bin/console commands default to running in dev mode. There are huge memory leaks that will consume GB of memory if you run a big import in dev mode.

To fix this, simply append your console command with --env=prod

Bundle Not Loading

Everything is case sensitive and there are lots of magic strings. You need to be totally sure that you have spelled things correctly and consistently across your various Yaml files and PHP files and class names.

If you want to check things, you can grep in the var/cache/dev/ folder, and can also set break points in /vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Product indexing

You might encounter that not all products are displayed in Akeneo. Therefore you need to reindex them.

1
2
cd /path/to/project/root/
bin/console pim:product:index --all

Installing sample dataset

You might want to start from scratch using default Akeneo dataset. Therefore you should execute command below.

1
2
cd /path/to/project/root
bin/console pm:installer:db --env=prod

Danger

Make sure to backup your database, as the command above, will completely wipe out your current database data.

Reset elasticsearch indexes

You might want to do that after switching to different database.

1
bin/console akeneo:elasticsearch:reset-indexes

Table akeneo_file_storage_file_info in Akeneo

Truncate this table before importing products to Akeneo, otherwise you might get image warnings and images will not be saved correctly.

And clear file_storage/catalog directory.