0

When I do export of products to csv all 'additional_attributes' are in one column.

This is not comfortable to read for client or content manager via MsExcel for example. Need that all the custom attributes were in separate columns.

Any ideas how to implement this feature or how to make this manually?

Maybe somewhere exist a free or paid module with required functionality?

3 Answers 3

0

This may not have been around when you asked this question almost 3 years ago, but, yes, there is a free extension that claims to do what you need: BSS Custom Product Attribute Export.

It states that you can select which attributes to "break out" into their own separate columns in the exported CSV file.

(Here is a link to the extension on Magento Marketplace.)

0

I extend my apologies for reactivating this post; however, I deem it pertinent to present a solution to the ongoing issue.

The following Python script facilitates the generation of an Excel file, organizing additional attributes into distinct columns. I trust this proves beneficial to you.

import sys
import pandas as pd

# Verifica que se hayan proporcionado suficientes argumentos
if len(sys.argv) < 3:
    print("Usage: python magento-additional_attributes.py input_file.csv output_file.xlsx")
    sys.exit(1)

# Obtén los nombres de archivo de entrada y salida desde los argumentos de la línea de comandos
input_file = sys.argv[1]
output_file = sys.argv[2]

# Lee el archivo CSV
df = pd.read_csv(input_file)

# Divide la columna 'additional_attributes' en atributos individuales
df['additional_attributes'] = df['additional_attributes'].fillna('')
attributes_list = df['additional_attributes'].str.split(',')

# Inicializa un nuevo DataFrame para el archivo de Excel
excel_df = pd.DataFrame(columns=['sku'])

# Itera sobre la lista de atributos y agrega columnas al nuevo DataFrame
for index, attributes in enumerate(attributes_list):
    row_data = {'sku': df.at[index, 'sku']}
    for attribute in attributes:
        key_value = attribute.split('=')
        if len(key_value) == 2:
            key, value = key_value
            if key not in excel_df.columns:
                excel_df[key] = ''
            row_data[key] = value
    excel_df = excel_df.append(row_data, ignore_index=True)

# Rellena los valores vacíos con la cadena "VACIO"
excel_df = excel_df.fillna('VACIO')

# Guarda el resultado en un archivo Excel
excel_df.to_excel(output_file, index=False)

-1

Magento 2 admin includes enhanced export functionality. You can export products to CSV with any related attributes you have. You can also filter products by some attributes before export. If you are looking for more flexible export tools or need to export them selectively, you can look for some at www.magentocommerce.com for example magento manager

1
  • Thanks and seems like you didn't get the problem I describe in question. :) I don't need to filter or exclude attributes from csv, I need to make 'additional_attributes' (custom attributes) readable in csv.
    – white-imp
    Sep 14, 2016 at 13:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.