           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

            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
