   ###
   Outputs given product definition as a file in JSON format.
   @param {object} productTypeDefinition The object containing product type definition.
-  ###
-  _writeFile: (productTypeDefinition, path) ->
+  @param {string} target The target folder for the file.
+  @param {string} prefix The prefix will be added to the resulting file name.
+  ###
+  _writeFile: (productTypeDefinition, target, prefix = 'product-type') ->
 
     prettified = JSON.stringify productTypeDefinition, null, 4
 
-    fileName = "#{@_options.target}/product-type-#{productTypeDefinition[PRODUCT_TYPE_NAME]}.json"
+    fileName = "#{target}/#{prefix}-#{productTypeDefinition[PRODUCT_TYPE_NAME]}.json"
     fs.writeFile fileName, prettified, (error) ->
       if error
         console.log "Error while writing file #{fileName}: #{error}"

        name: row['name']
        description: row['description']

      productTypeDefinitions.push productTypeDefinition

    productTypeDefinitions

  Creates sphere product type representation files using JSON format.
  @param {array} types Entire types CSV as an array of records.
  @param {array} attributes Entire attributes CSV as an array of records.
  @param {string} target The target folder for the generated files.
  @param {boolean} masterRetailerProject Set to true if product type files are used for a master/retailer projects, otherwise false.
  @param {function} callback The callback function to be invoked when the method finished its work.
  @return Result of the given callback
  ###
  run: (types, attributes, target, masterRetailerProject, callback) ->

    # build object with all attribute defintions for later usage
    attributeDefinitions = @_createAttributeDefinitions attributes

    # build product type definitions
    productTypeDefinitions = @_createProductTypesDefinitions types, attributeDefinitions

    # outpur product type files
    for productTypeDefinition in productTypeDefinitions
      @_writeFile productTypeDefinition, target

    # handle master/retailer product types
    if masterRetailerProject
      # create attribute definition 'masterSKU'
      attributeDefinitionMasterSku = @_createAttributeDefinitionMasterSku()
      # build product type definitions used in retailer projects
      productTypeDefinitionsRetailers = @_createProductTypesDefinitions types, attributeDefinitions, attributeDefinitionMasterSku

      # outpur product type files
      for productTypeDefinition in productTypeDefinitionsRetailers
        @_writeFile productTypeDefinition, target, 'retailer-product-type'

    callback true

