Advanced CSV Connector is an extension of classic Akeneo CSV Connector. It allows to customize columns mapping on import or export with JSON as job parameter.
Made by ❤️ by C&M
Add package with composer:
composer require clickandmortar/advanced-csv-connector-bundle "^1.0"
Add bundle in your app/AppKernel.php
file:
$bundles = array(
...
new ClickAndMortar\AdvancedCsvConnectorBundle\ClickAndMortarAdvancedCsvConnectorBundle(),
);
To create a new import job based on Advanced CSV connector, go to Imports
part and create a new job with type Import des produits avancé (CSV)
.
After job creation, go to edition mode and update Mapping
parameter in global parameters tab.
Import mapping example:
{
"attributes": [
{
"attributeCode": "ean_code",
"dataCode": "codeEan",
"identifier": true
},
{
"attributeCode": "lens_height",
"dataCode": "hauteurVerre",
"callback": "setMetricUnitAsSuffix"
},
{
"attributeCode": "universe",
"dataCode": "style",
"onlyOnCreation": true,
"locales": [
"fr_FR",
"en_GB"
]
},
{
"attributeCode": "age_range",
"dataCode": "trancheAge",
"normalizerCallback": "getAgeRange"
},
{
"attributeCode": "life_cycle",
"dataCode": "idCycleVie",
"defaultValue": "1"
},
{
"attributeCode": "price-EUR",
"dataCode": "prix"
}
],
"normalizers": [
{
"code": "getAgeRange",
"values": [
{
"normalizedValue": "0-18",
"originalValues": [
"5",
"12"
]
},
{
"normalizedValue": "18-35",
"originalValues": [
"19",
"26"
]
},
{
"normalizedValue": "35-50",
"originalValues": [
"38"
]
}
}
]
}
Mapping explanation:
identifier
(mandatory): Used to defined main identifier attribute of productattributes
(mandatory): This is the default key that must contain mapping for all output/input attributesattributeCode
(mandatory): The attribute code in your Akeneo projectdataCode
(mandatory): The column name in your filecallback
: The method name in your import helper to transform data from CSV filedefaultValue
: Default value for attribute if empty data in fileonlyOnCreation
: Set attribute value only if product is new (checked withidentifier
attribute)locales
: Used to set same attribute value for different locales
To create a new export job based on Advanced CSV connector, go to Exports
part and create a new job with type Export des produits avancé (CSV)
.
After job creation, go to edition mode and update Mapping
parameter in global parameters tab.
Export mapping example:
{
"columns": [
{
"attributeCode": "sku",
"columnName": "Code reference"
},
{
"attributeCode": "ean_code",
"columnName": "EAN Code",
"forcedValue": "Same code"
},
{
"attributeCode": "family_code",
"columnName": "Family code",
"normalizerCallback": "getNormalizedFamily"
},
{
"attributeCode": "age_range",
"columnName": "Age",
"callback": "completeAgeRange"
}
],
"normalizers": [
{
"code": "getNormalizedFamily",
"values": [
{
"normalizedValue": "Man",
"originalValues": [
"12",
"121",
"122"
]
}
]
}
],
"replacements": [
{
"values": [
"!"
],
"newValue": "!!!"
}
],
"additionalColumns": [
{
"columnName": "Additional column",
"value": "Same content"
}
]
}
Mapping explanation:
columns
(mandatory): Contains all columns mapping for exportattributeCode
(mandatory): Attribute code in Akeneo for column mappingcolumnName
: Custom column name in CSV exported fileforcedValue
: Force a valuenormalizerCallback
: Normalizer code to update value from Akeneocallback
: Method name in ImportHelper to update value from Akeneo
normalizers
: List of available normalizers used in mappingreplacements
: Replace values by newValue in all columnsadditionalColumns
: Force static columns in CSV exported file