diff --git a/CHANGELOG.md b/CHANGELOG.md index 606c703..7b62b3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Jenkinsfile b/Jenkinsfile index 69d3c0e..a2393f8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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": "git@github.com: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": "git@github.com: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() diff --git a/README.md b/README.md index 4cdb593..f65d3c6 100644 --- a/README.md +++ b/README.md @@ -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.* | @@ -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://git@distribution.akeneo.com:443/IcecatConnector", "branch": "master"}' composer require akeneo/icecat-connector 1.1.* ``` @@ -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 @@ -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. diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index c0db597..1cfa32e 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -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() @@ -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], diff --git a/src/DependencyInjection/PimIcecatConnectorExtension.php b/src/DependencyInjection/PimIcecatConnectorExtension.php index 7e8f83a..ccea4c3 100644 --- a/src/DependencyInjection/PimIcecatConnectorExtension.php +++ b/src/DependencyInjection/PimIcecatConnectorExtension.php @@ -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'); } } diff --git a/src/Form/Type/MassAction/IcecatEnrichmentType.php b/src/Form/Type/MassAction/IcecatEnrichmentType.php new file mode 100644 index 0000000..865caed --- /dev/null +++ b/src/Form/Type/MassAction/IcecatEnrichmentType.php @@ -0,0 +1,37 @@ + + * @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'; + } +} diff --git a/src/Mapping/Constraint/IgnoreFlagConstraintValidator.php b/src/Mapping/Constraint/IgnoreFlagConstraintValidator.php index 55f3004..686f9fd 100644 --- a/src/Mapping/Constraint/IgnoreFlagConstraintValidator.php +++ b/src/Mapping/Constraint/IgnoreFlagConstraintValidator.php @@ -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(); } diff --git a/src/MassEditAction/Operation/IcecatEnrichment.php b/src/MassEditAction/Operation/IcecatEnrichment.php new file mode 100644 index 0000000..2630ddd --- /dev/null +++ b/src/MassEditAction/Operation/IcecatEnrichment.php @@ -0,0 +1,44 @@ + + * @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 []; + } +} diff --git a/src/Resources/config/form_types.yml b/src/Resources/config/form_types.yml new file mode 100644 index 0000000..81f33c3 --- /dev/null +++ b/src/Resources/config/form_types.yml @@ -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 } diff --git a/src/Resources/config/jobs.yml b/src/Resources/config/jobs.yml index 3681652..c154321 100644 --- a/src/Resources/config/jobs.yml +++ b/src/Resources/config/jobs.yml @@ -40,29 +40,20 @@ services: pim_icecat_connector.job.enrich_products_init: class: '%pim_connector.job.simple_job.class%' arguments: - - 'icecat_enrich_products' + - 'mass_edit_icecat_enrichment' - '@event_dispatcher' - '@akeneo_batch.job_repository' - - - '@pim_icecat_connector.step.enrich_products_init' + - '@pim_icecat_connector.step.icecat_enrichment.mass_edit' tags: - name: akeneo_batch.job connector: 'Icecat' - type: '%pim_connector.job.import_type%' + type: '%pim_enrich.job.mass_edit_type%' #-------------------------------------------------------------------------- # Default providers #-------------------------------------------------------------------------- - pim_icecat_connector.job.job_parameters.default_values_provider.enrich_products: - class: Pim\Bundle\IcecatConnectorBundle\JobParameters\DefaultValuesProvider\EnrichProducts - arguments: - - - - 'icecat_enrich_products' - - [] - tags: - - { name: akeneo_batch.job.job_parameters.default_values_provider } - pim_icecat_connector.job.job_parameters.default_values_provider.download_xml_to_csv: class: Pim\Bundle\IcecatConnectorBundle\JobParameters\DefaultValuesProvider\XmlToCsvDownload arguments: @@ -118,3 +109,19 @@ services: icecat_import_features_mapping: icecat-job-instance-csv-to-csv-import tags: - { name: pim_enrich.provider.form, priority: 100 } + + pim_icecat_connector.connector.job.job_parameters.default_values_provider.product_mass_edit: + class: '%pim_enrich.connector.job.job_parameters.default_values_provider.product_mass_edit.class%' + arguments: + - + - 'mass_edit_icecat_enrichment' + tags: + - { name: akeneo_batch.job.job_parameters.default_values_provider } + + pim_icecat_connector.connector.job.job_parameters.constraint_collection_provider.product_mass_edit: + class: '%pim_enrich.connector.job.job_parameters.constraint_collection_provider.product_mass_edit.class%' + arguments: + - + - 'mass_edit_icecat_enrichment' + tags: + - { name: akeneo_batch.job.job_parameters.constraint_collection_provider } \ No newline at end of file diff --git a/src/Resources/config/mass_actions.yml b/src/Resources/config/mass_actions.yml new file mode 100644 index 0000000..0135c3c --- /dev/null +++ b/src/Resources/config/mass_actions.yml @@ -0,0 +1,14 @@ +services: + pim_icecat_mass_action.operation.icecat_enrichment: + public: false + class: Pim\Bundle\IcecatConnectorBundle\MassEditAction\Operation\IcecatEnrichment + arguments: + - 'mass_edit_icecat_enrichment' + tags: + - + name: pim_enrich.mass_edit_action + alias: icecat-enrichment + acl: pim_enrich_product_edit_attributes + datagrid: product-grid + operation_group: mass-edit + form_type: pim_icecat_mass_action_operation_icecat_enrichment diff --git a/src/Resources/config/parameters.yml b/src/Resources/config/parameters.yml index ce5f1a7..685d475 100644 --- a/src/Resources/config/parameters.yml +++ b/src/Resources/config/parameters.yml @@ -2,5 +2,4 @@ parameters: pim_icecat_connector.endpoint.server: 'https://data.icecat.biz/xml_s3/xml_server3.cgi' pim_icecat_connector.endpoint.product.prod_id: 'prod_id=%%s;vendor=%%s;lang=int;output=productxml' pim_icecat_connector.endpoint.product.ean: 'ean_upc=%%s;lang=en;output=productxml' - pim_icecat_connector.fallback_locale: 'en_US' pim_icecat_connector.fallback_channel: 'ecommerce' diff --git a/src/Resources/config/services.yml b/src/Resources/config/services.yml index acd1726..a4acfef 100644 --- a/src/Resources/config/services.yml +++ b/src/Resources/config/services.yml @@ -28,7 +28,6 @@ services: - '@pim_catalog.repository.attribute' - '@pim_extended_measures.repository' - '%pim_icecat_connector.fallback_channel%' - - '%pim_icecat_connector.fallback_locale%' pim_icecat_connector.mapping.attribute_mapper: class: Pim\Bundle\IcecatConnectorBundle\Mapping\AttributeMapper diff --git a/src/Resources/config/steps.yml b/src/Resources/config/steps.yml index c1f9957..5902117 100644 --- a/src/Resources/config/steps.yml +++ b/src/Resources/config/steps.yml @@ -19,12 +19,12 @@ services: - '@pim_icecat_connector.processor.mapping.features_mapping' - '@pim_icecat_connector.writer.file.csv_ouput' - pim_icecat_connector.step.enrich_products_init: + pim_icecat_connector.step.icecat_enrichment.mass_edit: class: '%pim_connector.step.item_step.class%' arguments: - - 'import' + - 'mass_edit_icecat_enrichment' - '@event_dispatcher' - '@akeneo_batch.job_repository' - - '@pim_icecat_connector.reader.database.product' + - '@pim_connector.reader.database.product' - '@pim_icecat_connector.processor.enrich.product' - '@pim_connector.writer.database.product' diff --git a/src/Resources/public/js/form/system.js b/src/Resources/public/js/form/system.js index 98be1ba..cb60d22 100644 --- a/src/Resources/public/js/form/system.js +++ b/src/Resources/public/js/form/system.js @@ -29,6 +29,7 @@ define([ label: __('pim_icecat_connector.configuration.tab.label'), template: _.template(template), areCredentialsValid: null, + fallbackChannel: null, supportedLocales: [ {id: 'INT', text: "International standardized version"}, {id: 'EN', text: "Standard or UK English"}, @@ -119,6 +120,8 @@ define([ this.getFormData()['pim_icecat_connector___locales'].value : '', fallback_locale: this.getFormData()['pim_icecat_connector___fallback_locale'] ? this.getFormData()['pim_icecat_connector___fallback_locale'].value : '', + scope: this.getFormData()['pim_icecat_connector___scope'] ? + this.getFormData()['pim_icecat_connector___scope'].value : '', credentials_username: this.getFormData()['pim_icecat_connector___credentials_username'] ? this.getFormData()['pim_icecat_connector___credentials_username'].value : '', credentials_password: this.getFormData()['pim_icecat_connector___credentials_password'] ? @@ -146,6 +149,22 @@ define([ } }; + + + FetcherRegistry.getFetcher('channel').search() + .then(function (channel) { + var choices = _.chain(channel) + .map(function (channel) { + return ChoicesFormatter.formatOne(channel); + }) + .value(); + initSelect2.init(this.$('#scope'), { + data: choices, + multiple: false, + containerCssClass: 'input-xxlarge' + }); + }.bind(this)); + FetcherRegistry.getFetcher('attribute').search(searchOptions) .then(function (attributes) { var choices = _.chain(attributes) diff --git a/src/Resources/public/js/templates/system/group/configuration.html b/src/Resources/public/js/templates/system/group/configuration.html index b8de69e..73d7134 100644 --- a/src/Resources/public/js/templates/system/group/configuration.html +++ b/src/Resources/public/js/templates/system/group/configuration.html @@ -132,6 +132,21 @@ +
+
+ +
+
+ +
+ +
+