Skip to content

Commit

Permalink
MKP-362: enrichment uses mass edit (#23)
Browse files Browse the repository at this point in the history
* MKP-362: enrichment uses mass edit
* MKP-362: updated README.md instructions
* MKP-362: added channel selector in icecat configuration
* Update documentation: README and CHANGELOG
  • Loading branch information
Remy Betus authored and jmleroux committed Oct 26, 2017
1 parent 7ecf291 commit d1eecf9
Show file tree
Hide file tree
Showing 19 changed files with 279 additions and 93 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 1.1.8
# 1.2.0
## Improvements
- MKP-478: Icecat connector integration tests
- MKP-362: add mass edit operation to enrich products

# 1.1.7
## Improvements
Expand Down
100 changes: 40 additions & 60 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,70 +42,50 @@ if (launchIntegrationTests.equals("yes")) {

def runIntegrationTest(phpVersion, mysqlVersion) {
node('docker') {
deleteDir()
cleanUpEnvironment()

def workspace = "/home/docker/pim"

sh "docker network create akeneo"
sh """
docker pull mysql:${mysqlVersion}
docker pull carcel/akeneo:php-${phpVersion}
"""

sh "docker run -d --network akeneo --name mysql \
-e MYSQL_ROOT_PASSWORD=root -e MYSQL_USER=akeneo_pim -e MYSQL_PASSWORD=akeneo_pim -e MYSQL_DATABASE=akeneo_pim \
mysql:${mysqlVersion} \
--sql-mode=ERROR_FOR_DIVISION_BY_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

unstash "pim_enterprise"

sh "docker run -d --network akeneo --name akeneo \
-e WORKSPACE=${workspace} -e COMPOSER_HOME=/home/docker/.composer \
-v /home/akeneo/.composer:/home/docker/.composer -v \$(pwd):${workspace} \
-w ${workspace} \
carcel/akeneo:php-${phpVersion}"

sh "docker ps -a"

try {
if (phpVersion != "5.6") {
sh "docker exec akeneo composer require --no-update alcaeus/mongo-php-adapter"
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"
}
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"
}
}

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

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

sh """
mkdir -p app/build/logs/
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
"""

sh "docker exec akeneo app/console pim:install --force --env=test"

sh 'mkdir -p app/build/logs/'
sh 'docker exec akeneo bin/phpunit -c app/phpunit.xml --log-junit app/build/logs/phpunit.xml'

} finally {
junit "app/build/logs/*.xml"
deleteDir()
Expand Down
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The Icecat Connector gives the capability to enrich Akeneo PIM product data with

| IcecatConnectorBundle | Akeneo PIM Community Edition |
|:---------------------:|:----------------------------:|
| 1.2.* | v1.7.* |
| 1.1.* | v1.7.* |
| 1.0.* | v1.6.* |

Expand Down Expand Up @@ -48,6 +49,7 @@ There are 3 differents imports profiles in this extension:
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.1.*
```

Expand Down Expand Up @@ -82,6 +84,11 @@ In `app/AppKernel.php`:
}
```

### 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
Expand All @@ -95,6 +102,65 @@ akeneo_storage_utils:
override: Pim\Bundle\ExtendedCeBundle\Model\ProductValue
```

### Mapping between Icecat locales and PIM locales
By default, content in specific language are set into one locale. Here is the existing mapping:

| Icecat locale | PIM Locale
|---------------|-----------
ZH_TW | zh_TW (Chinese - traditional))
EN_SG | en_SG (Singapore English)
EN_IN | en_IN (Indian English)
DE_CH | de_CH (Swiss German)
INT | null (International standardized version)
EN | en_GB (Standard or UK English)
US | en_US (US English)
NL | nl_NL (Dutch)
FR | fr_FR (French)
DE | de_DE (German)
IT | it_IT (Italian)
ES | es_ES (Spanish)
DK | da_DK (Danish)
RU | ru_RU (Russian)
PT | pt_PT (Portuguese)
BR | pt_BR (Brazilian Portuguese)
ZH | zh_CN (Chinese (simplified))
SE | sv_SE (Swedish)
PL | pl_PL (Polish)
CZ | cs_CZ (Czech)
HU | hu_HU (Hungarian)
FI | fi_FI (Finnish)
NO | nn_NO (Norwegian)
TR | tr_TR (Turkish)
BG | bg_BG (Bulgarian)
KA | ka_GE (Georgian)
RO | ro_RO (Romanian)
SR | sr_RS (Serbian)
JA | ja_JP (Japanese)
UK | uk_UA (Ukrainian)
CA | ca_ES (Catalan)
HR | hr_HR (Croatian)
AR | ar_SA (Arabic (Saudi Arabia))
VI | vi_VN (Vietnamese)
HE | he_IL (Hebrew)
KO | ko_KR (Korean)
LT | lt_LT (Lithuanian)
LV | lv_LV (Latvian)
ID | id_ID (Indonesian)
SK | sk_SK (Slovakian)

If you need to customize, please add the following section in your `app/config/config.yml`:

```yaml
pim_icecat_connector:
locale_mapping:
EN:
label: "Standard or UK English"
locale: en_GB
```
You can change any mapping this way. Only your changes are to be redefined, no need to rewrite
all of them.
### (Optionnal) Example bundles
This connector is shipped with complete example bundle, especially to override the ProductValue model.
Expand Down
2 changes: 2 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function getConfigTreeBuilder()
->scalarNode('ean_attribute')->end()
->scalarNode('fallback_locale')->end()
->scalarNode('locales')->end()
->scalarNode('scope')->end()
->scalarNode('description')->end()
->scalarNode('short_description')->end()
->scalarNode('summary_description')->end()
Expand All @@ -45,6 +46,7 @@ public function getConfigTreeBuilder()
'ean_attribute' => ['value' => null],
'fallback_locale' => ['value' => null],
'locales' => ['value' => null],
'scope' => ['value' => null],
'description' => ['value' => null],
'short_description' => ['value' => null],
'summary_description' => ['value' => null],
Expand Down
10 changes: 6 additions & 4 deletions src/DependencyInjection/PimIcecatConnectorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ class PimIcecatConnectorExtension extends Extension
public function load(array $configs, ContainerBuilder $container)
{
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('parameters.yml');
$loader->load('form_types.yml');
$loader->load('jobs.yml');
$loader->load('steps.yml');
$loader->load('readers.yml');
$loader->load('mass_actions.yml');
$loader->load('parameters.yml');
$loader->load('processors.yml');
$loader->load('writers.yml');
$loader->load('readers.yml');
$loader->load('services.yml');
$loader->load('steps.yml');
$loader->load('writers.yml');
}
}
37 changes: 37 additions & 0 deletions src/Form/Type/MassAction/IcecatEnrichmentType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Pim\Bundle\IcecatConnectorBundle\Form\Type\MassAction;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

/**
* This form type is used to provide possible users choices when performing the "icecat enrichment" mass action.
* Since there are no information to expect from users, the class does not add any field to the form.
*
* @author Remy Betus <[email protected]>
* @copyright 2017 Akeneo SAS (http://www.akeneo.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
class IcecatEnrichmentType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(
[
'data_class' => 'Pim\\Bundle\\IcecatConnectorBundle\\MassEditAction\\Operation\\IcecatEnrichment'
]
);
}

/**
* {@inheritdoc}
*/
public function getName()
{
return 'pim_icecat_mass_action_operation_icecat_enrichment';
}
}
4 changes: 2 additions & 2 deletions src/Mapping/Constraint/IgnoreFlagConstraintValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class IgnoreFlagConstraintValidator extends ConstraintValidator
public function validate($item, Constraint $constraint)
{
$ignoreFlag = $item['ignore_flag'];
$alowedValues = ['0', '1'];
if (!in_array($ignoreFlag, $alowedValues)) {
$allowedValues = ['0', '1'];
if (!in_array($ignoreFlag, $allowedValues)) {
$message = sprintf($constraint->message, $ignoreFlag);
$this->context->buildViolation($message)->addViolation();
}
Expand Down
44 changes: 44 additions & 0 deletions src/MassEditAction/Operation/IcecatEnrichment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace Pim\Bundle\IcecatConnectorBundle\MassEditAction\Operation;

use Pim\Bundle\EnrichBundle\MassEditAction\Operation\AbstractMassEditOperation;

/**
* This class describes what actions and options are available for the mass action.
* In this case, we don't need to specify any of them as:
* - locale/fallback locale are set in the Configuration screen
* - channel choice is also set in the Configuration screen.
*
* In the future, it may be an idea to update this part so one can choose a different locale on-the-fly.
*
* @author Remy Betus <[email protected]>
* @copyright 2017 Akeneo SAS (http://www.akeneo.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
class IcecatEnrichment extends AbstractMassEditOperation
{
/**
* {@inheritdoc}
*/
public function getOperationAlias()
{
return 'icecat-enrichment';
}

/**
* {@inheritdoc}
*/
public function getFormType()
{
return 'pim_icecat_mass_action_operation_icecat_enrichment';
}

/**
* {@inheritdoc}
*/
public function getFormOptions()
{
return [];
}
}
5 changes: 5 additions & 0 deletions src/Resources/config/form_types.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
pim_icecat.mass_action.form.type.icecat_enrichment:
class: Pim\Bundle\IcecatConnectorBundle\Form\Type\MassAction\IcecatEnrichmentType
tags:
- { name: form.type, alias: pim_icecat_mass_action_operation_icecat_enrichment }
Loading

0 comments on commit d1eecf9

Please sign in to comment.