     # this will sort the actions ranked in asc order (first 'remove' then 'add')
     _.sortBy actions, (a)-> a.action is "addPrice"
 
-  actionsMapVariantAttributes = (attributes, variant) ->
+  actionsMapVariantAttributes = (attributes, variant, allSameValueAttributeNames) ->
     actions = []
     if attributes
       _.each attributes, (value, key) ->

            actions.push setAction if setAction
          else
            index = key.substring(1)
            setAction = buildSetAttributeAction(value.value, variant, index)
            actions.push setAction if setAction

    actions

  # we assume that the products have the same ProductType
  # TODO: validate ProductType between products
  actionsMapAttributes: (diff, new_obj) ->
    actions = []
    # masterVariant
    masterVariant = diff.masterVariant
    if masterVariant
      attributes = masterVariant.attributes
      mActions = actionsMapVariantAttributes attributes, new_obj.masterVariant
      actions = actions.concat mActions

    # variants
    if diff.variants
      _.each diff.variants, (variant, i)->
        attributes = variant.attributes
        vActions = actionsMapVariantAttributes attributes, new_obj.variants[i]
        actions = actions.concat vActions

    actions


  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
