Skip to content

Commit

Permalink
PIM 2.0 migration (#29)
Browse files Browse the repository at this point in the history
* MKP-688: PIM 2.0 compatibility
* Update documentation
* Migrate jobs to 2.0
* fix specs
* PIM 2.0 migration: composer update
* PIM 2.0 migration: fix Travis
* PIM 2.0 migration: fix Jenkins
* PIM 2.0 migration: update README
  • Loading branch information
jmleroux authored Nov 10, 2017
1 parent 7deeb5d commit 1ed15d8
Show file tree
Hide file tree
Showing 83 changed files with 7,440 additions and 1,762 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
bin
vendor
.php_cs.cache
docker-compose.yml
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: php

php:
- 5.6
- 7.1

git:
depth: 10
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# 2.0.0
## Improvements
- MKP-688: PIM 2.0 compatibility

## BC breaks
- Rename form extension `icecat-job-instance-csv-base-import-show` to `icecat-job-instance-xml-base-import-show`
- Rename form extension `icecat-job-instance-csv-base-import-edit` to `icecat-job-instance-xml-base-import-edit`

# 1.2.2
## Improvements
- MKP-719: MKP-719: revert enrich job to its previous name to avoid BC break
Expand Down
83 changes: 41 additions & 42 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
def launchIntegrationTests = "no"

class Globals {
static pimVersion = "1.7"
static extensionBranch = "1.2.x-dev"
static mysqlVersion = "5.5"
static pimVersion = "2.0"
static extensionBranch = "2.0.x-dev"
static mysqlVersion = "5.7"
}

stage("Checkout") {
Expand Down Expand Up @@ -34,7 +34,7 @@ if (launchIntegrationTests.equals("yes")) {
stage("Integration tests") {
def tasks = [:]

tasks["phpunit-5.6-ee"] = {runIntegrationTest("5.6", "${Globals.mysqlVersion}")}
tasks["phpunit-7.1-ee"] = {runIntegrationTest("7.1", "${Globals.mysqlVersion}")}

parallel tasks
}
Expand All @@ -45,45 +45,44 @@ def runIntegrationTest(phpVersion, mysqlVersion) {
cleanUpEnvironment()

try {
docker.image("mysql:5.5")
.withRun("--name mysql -e MYSQL_ROOT_PASSWORD=root -e MYSQL_USER=akeneo_pim -e MYSQL_PASSWORD=akeneo_pim -e MYSQL_DATABASE=akeneo_pim --tmpfs=/var/lib/mysql/:rw,noexec,nosuid,size=1000m --tmpfs=/tmp/:rw,noexec,nosuid,size=300m") {
docker.image("akeneo/php:5.6")
.inside("--link mysql:mysql -v /home/akeneo/.composer:/home/akeneo/.composer -e COMPOSER_HOME=/home/akeneo/.composer") {
unstash "pim_enterprise"

if (phpVersion != "5.6") {
sh "composer require --no-update alcaeus/mongo-php-adapter"
}

sh """
composer config repositories.icecat '{"type": "vcs", "url": "[email protected]:akeneo/icecat-connector.git", "branch": "master"}'
php -d memory_limit=3G /usr/local/bin/composer require phpunit/phpunit:5.4.* akeneo/icecat-connector:${Globals.extensionBranch} --no-interaction --no-progress --prefer-dist
"""

dir("vendor/akeneo/icecat-connector") {
deleteDir()
unstash "icecat_extension"
docker.image("elasticsearch:5.5")
.withRun("--name elasticsearch -e ES_JAVA_OPTS=\"-Xms512m -Xmx512m\"") {
docker.image("mysql:5.7")
.withRun("--name mysql -e MYSQL_ROOT_PASSWORD=root -e MYSQL_USER=akeneo_pim -e MYSQL_PASSWORD=akeneo_pim -e MYSQL_DATABASE=akeneo_pim --tmpfs=/var/lib/mysql/:rw,noexec,nosuid,size=1000m --tmpfs=/tmp/:rw,noexec,nosuid,size=300m") {
docker.image("akeneo/php:${phpVersion}")
.inside("--link mysql:mysql --link elasticsearch:elasticsearch -v /home/akeneo/.composer:/home/docker/.composer -e COMPOSER_HOME=/home/docker/.composer") {
unstash "pim_enterprise"

sh """
composer config repositories.icecat '{"type": "vcs", "url": "[email protected]:akeneo/icecat-connector.git", "branch": "master"}'
php -d memory_limit=3G /usr/local/bin/composer require phpunit/phpunit:5.4.* akeneo/icecat-connector:${Globals.extensionBranch} --no-interaction --no-progress --prefer-dist
"""

dir("vendor/akeneo/icecat-connector") {
deleteDir()
unstash "icecat_extension"
}
sh 'composer dump-autoload -o'

sh """
rm app/cache/* -rf
sed -i 's#// your app bundles should be registered here#\\0\\nnew Pim\\\\Bundle\\\\IcecatConnectorBundle\\\\PimIcecatConnectorBundle(),#' app/AppKernel.php
sed -i 's#// your app bundles should be registered here#\\0\\nnew Pim\\\\Bundle\\\\ExtendedMeasureBundle\\\\PimExtendedMeasureBundle(),#' app/AppKernel.php
sed -i 's#// your app bundles should be registered here#\\0\\nnew Pim\\\\Bundle\\\\ExtendedAttributeTypeBundle\\\\PimExtendedAttributeTypeBundle(),#' app/AppKernel.php
cat app/AppKernel.php
"""

sh """
cp vendor/akeneo/icecat-connector/src/Resources/jenkins/parameters_test.yml app/config/parameters_test.yml
cat vendor/akeneo/icecat-connector/src/Resources/jenkins/routing.yml >> app/config/routing.yml
cp vendor/akeneo/icecat-connector/src/Resources/jenkins/phpunit.xml app/phpunit.xml
cat vendor/akeneo/icecat-connector/src/Resources/jenkins/config_test.yml >> app/config/config_test.yml
mkdir -p app/build/logs
"""
sh "sleep 10"
sh "bin/console pim:install --force --env=test"
sh "vendor/bin/phpunit -c app/phpunit.xml --log-junit app/build/logs/phpunit.xml"
}
sh 'composer dump-autoload -o'

sh """
rm app/cache/* -rf
sed -i 's#// your app bundles should be registered here#\\0\\nnew Pim\\\\Bundle\\\\IcecatConnectorBundle\\\\PimIcecatConnectorBundle(),#' app/AppKernel.php
sed -i 's#// your app bundles should be registered here#\\0\\nnew Pim\\\\Bundle\\\\ExtendedMeasureBundle\\\\PimExtendedMeasureBundle(),#' app/AppKernel.php
sed -i 's#// your app bundles should be registered here#\\0\\nnew Pim\\\\Bundle\\\\ExtendedAttributeTypeBundle\\\\PimExtendedAttributeTypeBundle(),#' app/AppKernel.php
cat app/AppKernel.php
"""

sh """
cp vendor/akeneo/icecat-connector/src/Resources/jenkins/parameters_test.yml app/config/parameters_test.yml
cat vendor/akeneo/icecat-connector/src/Resources/jenkins/routing.yml >> app/config/routing.yml
cp vendor/akeneo/icecat-connector/src/Resources/jenkins/phpunit.xml app/phpunit.xml
cat vendor/akeneo/icecat-connector/src/Resources/jenkins/config_test.yml >> app/config/config_test.yml
mkdir -p app/build/logs
"""

sh "app/console pim:install --force --env=test"
sh "bin/phpunit -c app/phpunit.xml --log-junit app/build/logs/phpunit.xml"
}
}
} finally {
Expand Down
52 changes: 8 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ It can be used with both Open Icecat free catalog or Full Icecat paid catalog.

| IcecatConnectorBundle | Akeneo PIM Community Edition |
|:---------------------:|:----------------------------:|
| 2.0.* | v2.0.* |
| 1.2.* | v1.7.* |
| 1.1.* | v1.7.* |
| 1.0.* | v1.6.* |
Expand Down Expand Up @@ -64,7 +65,7 @@ First, you must require the connector dependencies:

```php
composer config repositories.icecat '{"type": "vcs", "url": "ssh://[email protected]:443/IcecatConnector", "branch": "master"}'
composer require akeneo/icecat-connector 1.2.*
composer require akeneo/icecat-connector 2.0.*
```

## Registering the bundle
Expand All @@ -82,7 +83,7 @@ pim_icecat_connector:
### Register dependencies and override product value model
The Icecat connector uses a new attribute type to store pictures url collection.
You must then activate the dependencies bundles and add a custom one to override the original ProductValue class:
You must then activate the dependencies bundles:
In `app/AppKernel.php`:

Expand All @@ -93,24 +94,18 @@ In `app/AppKernel.php`:
new \Pim\Bundle\ExtendedAttributeTypeBundle\PimExtendedAttributeTypeBundle(),
new \Pim\Bundle\ExtendedMeasureBundle\PimExtendedMeasureBundle(),
new \Pim\Bundle\IcecatConnectorBundle\PimIcecatConnectorBundle(),
new \MyCompany\Bundle\MyBundle\MyPimBundle(), // Your custom bundle with overriden ProductValue
];
}
```

### Add new Mass Operation:
```
app/console akeneo:batch:create-job "Akeneo Mass Edit Connector" "mass_edit_icecat_enrichment" "mass_edit" "mass_edit_icecat_enrichment"
```
More explanation about the ProductValue override can be found in Akeneo documentation:
https://docs.akeneo.com/1.7/cookbook/catalog_structure/overriding_the_orm_product_value.html
Do not forget to update the mapping for your brand new product value in `app/config/config.yml`:

```yaml
akeneo_storage_utils:
mapping_overrides:
-
original: PimEnterprise\Component\Catalog\Model\ProductValue
override: Pim\Bundle\ExtendedCeBundle\Model\ProductValue
```

### Add new Mass Operation:
```
app/console akeneo:batch:create-job "Akeneo Mass Edit Connector" "mass_edit_icecat_enrichment" "mass_edit" "mass_edit_icecat_enrichment"
Expand All @@ -119,8 +114,6 @@ app/console akeneo:batch:create-job "Akeneo Mass Edit Connector" "mass_edit_icec
In an Enterpise Edition context, you must also add the corresponding permissions:
https://docs.akeneo.com/1.7/cookbook/mass_edition/register_a_new_mass_edit_action.html#phase-6-add-user-groups-permissions-to-job-profiles-enterprise-edition
Copy the mass edit view `icecat-enrichment.html.twig` in your `app/Resources` directory.
To facilitate this configuration, the bundle provides a `bin/setup.bash` to make this operations in one command line.
### Mapping between Icecat locales and PIM locales
Expand Down Expand Up @@ -169,37 +162,8 @@ LV | lv_LV (Latvian)
ID | id_ID (Indonesian)
SK | sk_SK (Slovakian)
### (Optionnal) Example bundles
This connector is shipped with complete example bundle, especially to override the ProductValue model.
This is needed to use the new TextCollection attribute type.
The easiest way to enable it is to use a symbolic link:
```
cd src
ln -s ../vendor/akeneo/extended-attribute-type/doc/example/Pim Pim
```
After that, you will be able to use the example bundles in `app/AppKernel.php`:
```php
protected function registerProjectBundles()
{
return [
new \Pim\Bundle\ExtendedAttributeTypeBundle\PimExtendedAttributeTypeBundle(),
new \Pim\Bundle\ExtendedMeasureBundle\PimExtendedMeasureBundle(),
new \Pim\Bundle\IcecatConnectorBundle\PimIcecatConnectorBundle(),
new \Pim\Bundle\ExtendedCeBundle\ExtendedCeBundle(), // example CE bundle to activate the extended attributes
//new \Pim\Bundle\ExtendedEeBundle\ExtendedEeBundle(), // example EE bundle to activate the extended attributes
];
}
```

### Update the DB schema
The ExtendedAttributeTypeBundle need to add some tables from the ProductValue override and you must update the Doctrine schema.

One way to this is using the command `app/console doctrine:schema:update`.
You will habe to specify an option for this command:
Expand Down
9 changes: 3 additions & 6 deletions bin/setup.bash
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#!/usr/bin/env bash

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
APP_DIR="$(readlink -e $SCRIPT_DIR/./../../../../app)"
APP_VIEWS_DIR="$APP_DIR/Resources/PimEnrichBundle/views"
echo $APP_DIR
mkdir -p $APP_VIEWS_DIR/MassEditAction/product/configure
cp ./../src/Resources/views/icecat-enrichment.html.twig $APP_VIEWS_DIR/MassEditAction/product/configure
BIN_DIR="$(readlink -e $SCRIPT_DIR/./../../../../bin)"

cd $APP_DIR
cd $BIN_DIR
echo $(pwd)
./console akeneo:batch:create-job "Akeneo Mass Edit Connector" "mass_edit_icecat_enrichment" "mass_edit" "mass_edit_icecat_enrichment"
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
}
],
"require": {
"php": ">=5.6.0",
"akeneo/extended-attribute-type": "1.1.*",
"php": ">=7.1",
"akeneo/extended-attribute-type": "2.0.*",
"akeneo/extended-measure-bundle": "0.1.*",
"akeneo/pim-community-dev": "1.7.*",
"akeneo/pim-community-dev": "2.0.*",
"guzzlehttp/guzzle": "6.*",
"prewk/xml-string-streamer": "0.9.*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "@stable",
"phpspec/phpspec": "@stable"
"phpspec/phpspec": "~3.4"
},
"autoload": {
"psr-4": {
Expand All @@ -40,7 +40,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.1.x-dev",
"dev-master": "2.0.x-dev",
"dev-1.0": "1.0.x-dev"
}
}
Expand Down
Loading

0 comments on commit 1ed15d8

Please sign in to comment.