import-cli-simple icon indicating copy to clipboard operation
import-cli-simple copied to clipboard

Array support for attribute set import

Open Morgy93 opened this issue 5 years ago • 2 comments

It would be awesome to have array support for the attribute set import. Currently:

for any additional Attribute Group a new row has to be added https://docs.m2if.com/38/file-structure/attributes-set-and-group-import/attribute-groups

But instead of

attribute_set_name based_on entity_type_code sort_order attribute_group_name attribute_group_code attribute_group_tab_group_code attribute_group_sort_order default_id
Bag   catalog_product 2 Product Details product-details basic 10 1
        Content content

I'd love to see something like the multiple-field-delimiter and multiple-value-delimiter which exists for product import https://docs.m2if.com/38/file-structure/product-import/additional-attributes

For example:

attribute_set_name based_on entity_type_code sort_order attribute_group attribute_group_tab_group_code attribute_group_sort_order default_id
Bag   catalog_product 2 name="Product Details"|code="product-details",name="Content"|code="content"|tab_group_code="advanced" basic 10 1

Morgy93 avatar Apr 03 '20 12:04 Morgy93

@Morgy93 I'll check this, but in general, it's much more complicated for most of our users/customers to create CSV files using that more or less complex data format you're requesting. For most of them, it's much easier to create a CSV file with additional columns or rows. But I'll check it and see if there is any possibility, therefore.

wagnert avatar Apr 04 '20 09:04 wagnert

Really? For me that has always been some pretty weird practice. For PHP and especially with Magento (collections and so on) I think it's rather stressful to have to build csv data like this.

Easy:

foreach ($products as $product) {
    fputcsv($handle, [
        $product->getSku(),
        $product->getName(),
        implode('|', $product->getCategoryIds()),
        ...
    ]);
}

Just one weird example which should at least show that it can get pretty complicated real quick 😁 :

foreach ($products as $product) {
    $categories = $product->getCategoryIds();
    fputcsv($handle, [
        $product->getSku(),
        $product->getName(),
        $categories[0],
        ...
    ]);
    if (count($categories) > 1) {
        foreach ($categories as $category) {
            fputcsv($handle, [
                '',
                '',
                $category,
                ...
            ]);
        }
    }
}

(After writing this I found out that it wouldn't even work like this with multiple array data .. but that should just make it even clearer 🤷‍♂ )

Just my two cents~

Morgy93 avatar Apr 07 '20 12:04 Morgy93