           else
             # key is index of attribute
             index = key
-            setAction = buildSetAttributeAction(value.value, variant, index)
+            setAction = buildSetAttributeAction(value.value, variant, index, allSameValueAttributeNames)
             actions.push setAction if setAction
         else if key.match(/^\_\d$/g)
           if _.isArray value

    # this will sort the actions ranked in asc order (first 'remove' then 'add')
    _.sortBy actions, (a)-> a.action is "addPrice"

  actionsMapVariantAttributes = (attributes, variant) ->
    actions = []
    if attributes
      _.each attributes, (value, key) ->


  action

buildNewSetAttributeAction = (id, el, allSameValueAttributeNames)->
  attributeName = el.name
  action =
    action: "setAttribute"
    variantId: id
    name: attributeName
    value: el.value
  if _.contains(allSameValueAttributeNames, attributeName)
    action.action = 'setAttributeInAllVariants'
  action
