Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | 354x 354x 4198x 4191x 18877x 9904x 18877x 3428x 3428x 17945x 3428x 3428x | 'use strict';
define(
['jquery', 'underscore', 'pim/fetcher-registry'],
function ($, _, FetcherRegistry) {
return {
/**
* Get all the attribute group for the given product
*
* @param {Object} product
*
* @return {Promise}
*/
getAttributeGroupsForObject: function (product) {
return FetcherRegistry.getFetcher('attribute-group').fetchAll()
.then(function (attributeGroups) {
return _.values(attributeGroups).reduce((result, attributeGroup) => {
//If one (or more) of the attributes of the attribute group is in the product we need to add it
if (_.intersection(attributeGroup.attributes, _.keys(product.values)).length > 0) {
result[attributeGroup.code] = attributeGroup;
}
return result;
}, {});
});
},
/**
* Get the attribute group for the given attribute
*
* @param {Array} attributeGroups
* @param {String} attributeCode
*
* @return {String}
*/
getAttributeGroupForAttribute: function (attributeGroups, attributeCode) {
var result = null;
_.each(attributeGroups, function (attributeGroup) {
if (-1 !== attributeGroup.attributes.indexOf(attributeCode)) {
result = attributeGroup.code;
}
});
return result;
}
};
});
|