instride-ch / pimcore-data-definitions

Data Definitions Plugin for Pimcore
Other
78 stars 58 forks source link

ImportDefinitions does not ignore non-mandatory fields #2

Closed Cruiser13 closed 8 years ago

Cruiser13 commented 8 years ago

I'm trying to import a CSV as objects using the importer. One of the object fields is missing in the CSV. It's a number field with the following settings: { "fieldtype":"numeric", "width":"", "defaultValue":null, "queryColumnType":"double", "columnType":"double", "phpdocType":"float", "integer":true, "unsigned":true, "minValue":1, "maxValue":99999, "decimalPrecision":null, "name":"postal", "title":"Postleitzahl", "tooltip":"", "mandatory":false, "noteditable":false, "index":false, "locked":false, "style":"", "permissions":null, "datatype":"data", "relationType":false, "invisible":false, "visibleGridView":false, "visibleSearch":false },

Importer error message is "[Pimcore\Model\Element\ValidationException] Value in field [ postal ] is not at least 1 fieldname=postal".

The error itself is correct but I believe it should still import the data because the field postal is not mandatory and does not even exist in CSV.

dpfaffenbauer commented 8 years ago

hmm.... the importer doesn't take care of validation, because this is done by pimcore. Could you please provider more information? eg. Class Export and CSV?

Cruiser13 commented 8 years ago

Looks like the issue is deeper within. CSV seems to need enclosure character which our CSV does not include:

ID;Anrede;Vorname;Nachname;Adresse;Telefon;Handy;E-Mail;Firma

It fails at Warning: fgetcsv(): enclosure must be a character in pimcore\plugins\ImportDefinitions\lib\ImportDefinitions\Model\Provider\Csv.php on line 149

So that does probably mess up the fields which does lead to the error above. Postal is filled with a wrong value I think.

dpfaffenbauer commented 8 years ago

thats fixed, could you please try it again?

Cruiser13 commented 8 years ago

Thanks, I investigated further. Fixing the error by reformating CSV does not fix the error above. Postal field does still seem to be an issue.

My current CSV:

"ID";"Anrede";"Vorname";"Nachname";"Adresse";"Telefon";"Handy";"E-Mail";"Firma"

My Importer settings are looking like this: importer

Postal is not set (because not provided by CSV). Might be a pimcore issue with min value.

Cruiser13 commented 8 years ago

Removing min and max value from the postal field does fix the issue. All other non-mandatory fields are being ignored properly. Looks like this is a pimcore issue with mandatory vs minimum values and not a plugin issue here. I'll push this to the main repository.

Edit: https://github.com/pimcore/pimcore/issues/722

dpfaffenbauer commented 8 years ago

:thumbsup:

dpfaffenbauer commented 8 years ago

related to https://github.com/pimcore/pimcore/issues/722