generateCombinationsWithAttributeCodes

generateCombinationsWithAttributeCodes ( array maps ) : array

Useful for magento. Generate combinations for ecommerce. The array is formed with id_attribute in key and id_attribute_value in value .

Example




	// Define the associative array with attribute codes and their corresponding values
attributeMaps = [
"color" : [
1 /*red*/ , 2 /*blue*/ , 3 /*green*/
],
"size" : [
10 /*S*/ , 11 /*M*/ , 12 /*L*/
]
]

// Generate the combinations using the function
combinations = generateCombinationsWithAttributeCodes(attributeMaps)

// Display the generated combinations
console(combinations) //-> [{color=1, size=10}, {color=2, size=10}, {color=3, size=10}, {color=1, size=11}, {color=2, size=11}, {color=3, size=11}, {color=1, size=12}, {color=2, size=12}, {color=3, size=12}]


See also

generateCombinations

Parameters

maps

associative array : [codeAttribute=>listAttributeValues]