FriendsOfSylius / SyliusImportExportPlugin

Sylius plugin to import / export data
MIT License
118 stars 82 forks source link

Import product fail #246

Open SofianeMerouane opened 3 years ago

SofianeMerouane commented 3 years ago

Hello, I'm trying to import a product, via the administration, but I have this error message

Erreur

The mandatory header-keys, "t_shirt_brand, t_shirt_collection, t_shirt_material, cap_brand, cap_collection, cap_material, dress_brand, dress_collection, dress_material, jeans_brand, jeans_collection, jeans_material, book_cover, Chaussures ahomme, Images_main, t_shirt_brand, t_shirt_collection, t_shirt_material, cap_brand, cap_collection, cap_material, dress_brand, dress_collection, dress_material, jeans_brand, jeans_collection, jeans_material, book_cover, Chaussures ahomme, Images_main", are missing in the data-set. Found header-keys are "Code, Locale, Name, Description, Short_description, Meta_description, Meta_keywords, Main_taxon, Taxons, Channels, Enabled, Price". Either change the service definition of the processor accordingly or update your import-data I don't understand why they require attribute values?

If anyone can help me please?

oallain commented 3 years ago

Hello @SofianeMerouane ,

I think this is due to the list of columns you have in your import file. Columns are defined in ProductProcessor here : https://github.com/FriendsOfSylius/SyliusImportExportPlugin/blob/7aa80b422e56c8d83918a207ba612be7f279abea/src/Resources/config/services.yml#L353

You must override this service definition and this ProductProcessor class to use your specific columns. https://github.com/FriendsOfSylius/SyliusImportExportPlugin/blob/7aa80b422e56c8d83918a207ba612be7f279abea/src/Processor/ProductProcessor.php#L139

I hope this will help you.

SofianeMerouane commented 3 years ago

Hello oallain, thank you for your answer, my import file is the plugin fixture file in tests / Behat / Resources / fixtures / products.csv, so the fields are: Code | Locale | Name | Description | Short_description | Meta_description | Meta_keywords | Main_taxon | Taxons | Channels | Enabled | Price. So my file does contain the fields specified in the configuration, and bearing the error message indicates that the keys are missing.

Erreur

The mandatory header-keys, t_shirt_brand, t_shirt_collection, t_shirt_material, cap_brand, cap_collection, cap_material, dress_brand, dress_collection, dress_material, jeans_brand, jeans_collection, jeans_material, book_cover: This is the list of attributes in my database, in fact in the class ProductProcessor.php

public function process(array $data): void { / /

    **$this->headerKeys = \array_merge($this->headerKeys, $this->attrCode);**
  /**
  **/

    $this->productRepository->add($product);
}

I do not understand why I am deamnde to re-enter attribute values ​​in my database, in the import file thank you in advance