From ee77819aca915cc324a1b54d621c904ac8bc8fde Mon Sep 17 00:00:00 2001 From: pkarw Date: Wed, 6 Feb 2019 18:19:52 +0100 Subject: [PATCH 1/2] Product indexer extended to set the `product.configurable_options.label` --- src/adapters/magento/product.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/adapters/magento/product.js b/src/adapters/magento/product.js index c88e2f2..fbed885 100644 --- a/src/adapters/magento/product.js +++ b/src/adapters/magento/product.js @@ -21,6 +21,19 @@ const serial = funcs => funcs.reduce((promise, func) => promise.then(result => func().then(Array.prototype.concat.bind(result))), Promise.resolve([])) + const optionLabel = (attr, optionId) => { + if (attr) { + let opt = attr.options.find((op) => { // TODO: cache it in memory + if (_.toString(op.value) === _.toString(optionId)) { + return op + } + }) // TODO: i18n support with multi website attribute names + return opt ? opt.label : optionId + } else { + return optionId + } +} + class ProductAdapter extends AbstractMagentoAdapter { constructor(config) { @@ -434,6 +447,9 @@ class ProductAdapter extends AbstractMagentoAdapter { let atr = JSON.parse(serializedAtr); // category object if (atr != null) { option.attribute_code = atr.attribute_code; + option.values.map((el) => { + el.label = optionLabel(atr, el.value_index) + } ) logger.info(`Product options for ${atr.attribute_code} for ${item.sku} set`); item[atr.attribute_code + '_options'] = option.values.map((el) => { return el.value_index } ) } From e73c40e7ed43311d31ec648e75f09acd5c81b1d8 Mon Sep 17 00:00:00 2001 From: pkarw Date: Wed, 6 Feb 2019 18:29:16 +0100 Subject: [PATCH 2/2] Changelog added --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eba55ec..d029ab8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added + - Setting `configurable_options.label` from the attribute meta descriptor. **Note:** When You modify any configurable attribute label in Magento You should reindex all products now - Configurable parent refresh sync - enabled in the `productsdelta` and `productsworker` modes and in `products --sku=`. This mode is refreshing the configurable parent product for the simple child which requires update. Its' required to start the `clis.js productsworker` (example call: `test_product_worker.sh`) for processing these parent updates, - Example calls added: `test_product_delta.sh` - for delta indexer, `test_product_worker.sh` for products worker, `test_fullreindex_multiprocess.sh` for multi process/parallel updates, `test_by_sky.sh` - for single SKU updates.