shuup.default_importer.importers package

Submodules

shuup.default_importer.importers.contact module

class shuup.default_importer.importers.contact.AddressHandlerMeta(handler, model)[source]

Bases: ImportMetaBase

aliases = {'name_ext': ['extension', 'ext']}

Post save handlers

You can directly assign post save handler for a field. Field That has post save handler assigned won’t be available for mapping and won’t cause it to appear in unmapped fields in importer.

The handler is being triggered if any of the given values in trigger list is being encountered while iterating.

This is a dictionary that contains list of values:

{function_name: [list_of_triggers]}

Example

post_save_handlers = {

“handle_row_address”: [‘city’, ‘country’, ‘postal code’, ‘region code’, ‘street’],

}

In this example the handle_row_address is being called when any of the triggers is being encountered.

post_save_handlers = {'handle_row_address': ['city', 'country', 'postal code', 'region code', 'street']}

Fields to skip

It’s sometimes necessary to skip fields in importer.

For now we are using this to skip image fields in ProductMetaBase.

handle_row_address(fields, row_session)[source]
presave_hook(sess)[source]

Pre-save Hook

This method is called before the row session is saved. This can be used to add data into row_session.instance

Parameters:

row_session (shuup.importer.importing.session.DataImporterRowSession) – Current row session

Returns:

None

class shuup.default_importer.importers.contact.PersonContactImporter(data, context)[source]

Bases: DataImporter

identifier = 'contact_importer'
name = 'Contact Importer'
meta_base_class

alias of AddressHandlerMeta

model

alias of Contact

example_files = [<shuup.importer.importing.importing.ImporterExampleFile object>]
get_row_model(row)[source]

Get model that matches the row.

Can be used in cases where you have multiple types of data in same import.

Parameters:

row – A row dict.

classmethod get_example_file_content(example_file, request)[source]

Returns a binary file that will be served through the request. This base implementation just renders a template and returns the result as BytesIO or StringIO. Override this method to return a custom file content.

:param request HttpRequest :rtype StringIO|BytesIO

class shuup.default_importer.importers.contact.CompanyContactImporter(data, context)[source]

Bases: DataImporter

identifier = 'company_importer'
name = 'Company Contact Importer'
meta_base_class

alias of AddressHandlerMeta

model

alias of Contact

example_files = [<shuup.importer.importing.importing.ImporterExampleFile object>]
get_row_model(row)[source]

Get model that matches the row.

Can be used in cases where you have multiple types of data in same import.

Parameters:

row – A row dict.

classmethod get_example_file_content(example_file, request)[source]

Returns a binary file that will be served through the request. This base implementation just renders a template and returns the result as BytesIO or StringIO. Override this method to return a custom file content.

:param request HttpRequest :rtype StringIO|BytesIO

shuup.default_importer.importers.product module

class shuup.default_importer.importers.product.ProductMetaBase(handler, model)[source]

Bases: ImportMetaBase

aliases = {'categories': ['extra_categories'], 'image': ['image', 'main_image'], 'keywords': ['tags'], 'manufacturer': ['mfgr'], 'media': ['media', 'images'], 'name': ['title'], 'parent_sku': ['parent sku'], 'primary_category': ['category', 'main_category'], 'qty': ['quantity', 'stock_amount', 'stock_qty', 'stock_quantity', 'qty'], 'suppliers': ['supplier'], 'tax_class': ['tax_class_name'], 'type': ['product_type', 'producttype'], 'variation_value_1': ['variation value 1'], 'variation_value_2': ['variation value 2'], 'variation_value_3': ['variation value 3'], 'variation_value_4': ['variation value 4']}

Post save handlers

You can directly assign post save handler for a field. Field That has post save handler assigned won’t be available for mapping and won’t cause it to appear in unmapped fields in importer.

The handler is being triggered if any of the given values in trigger list is being encountered while iterating.

This is a dictionary that contains list of values:

{function_name: [list_of_triggers]}

Example

post_save_handlers = {

“handle_row_address”: [‘city’, ‘country’, ‘postal code’, ‘region code’, ‘street’],

}

In this example the handle_row_address is being called when any of the triggers is being encountered.

fields_to_skip = ['ignore', 'shop_primary_image', 'primary_image']
post_save_handlers = {'handle_images': ['image', 'media'], 'handle_stocks': ['qty'], 'handle_variations': ['parent_sku', 'variation_value_1', 'variation_value_2', 'variation_value_3', 'variation value 4']}

Fields to skip

It’s sometimes necessary to skip fields in importer.

For now we are using this to skip image fields in ProductMetaBase.

handle_variations(fields, sess)[source]
handle_images(fields, sess)[source]

Handle images for product.

handle_stocks(fields, sess)[source]

Handle stocks for product.

If stock quantity has been given, expect that a supplier with stock management must be available.

presave_hook(sess)[source]

Pre-save Hook

This method is called before the row session is saved. This can be used to add data into row_session.instance

Parameters:

row_session (shuup.importer.importing.session.DataImporterRowSession) – Current row session

Returns:

None

postsave_hook(sess)[source]

Post-save Hook

This method is called after the row session is saved. This can be used to create related objects.

Parameters:

row_session (shuup.importer.importing.session.DataImporterRowSession) – Current row session

Returns:

None

get_import_defaults()[source]

Get default values for import time.

class shuup.default_importer.importers.product.ProductImporter(data, context)[source]

Bases: DataImporter

identifier = 'product_importer'
name = 'Product Importer'
meta_base_class

alias of ProductMetaBase

model

alias of Product

relation_field = 'product'
help_template = 'shuup/default_importers/product_help.jinja'
example_files = [<shuup.importer.importing.importing.ImporterExampleFile object>, <shuup.importer.importing.importing.ImporterExampleFile object>, <shuup.importer.importing.importing.ImporterExampleFile object>, <shuup.importer.importing.importing.ImporterExampleFile object>, <shuup.importer.importing.importing.ImporterExampleFile object>, <shuup.importer.importing.importing.ImporterExampleFile object>]
classmethod get_example_file_content(example_file, request)[source]

Returns a binary file that will be served through the request. This base implementation just renders a template and returns the result as BytesIO or StringIO. Override this method to return a custom file content.

:param request HttpRequest :rtype StringIO|BytesIO

classmethod get_help_context_data(request)[source]

Returns the context data that should be used for help texts in admin.

Module contents

class shuup.default_importer.importers.PersonContactImporter(data, context)[source]

Bases: DataImporter

example_files = [<shuup.importer.importing.importing.ImporterExampleFile object>]
classmethod get_example_file_content(example_file, request)[source]

Returns a binary file that will be served through the request. This base implementation just renders a template and returns the result as BytesIO or StringIO. Override this method to return a custom file content.

:param request HttpRequest :rtype StringIO|BytesIO

get_row_model(row)[source]

Get model that matches the row.

Can be used in cases where you have multiple types of data in same import.

Parameters:

row – A row dict.

identifier = 'contact_importer'
meta_base_class

alias of AddressHandlerMeta

model

alias of Contact

name = 'Contact Importer'
class shuup.default_importer.importers.CompanyContactImporter(data, context)[source]

Bases: DataImporter

example_files = [<shuup.importer.importing.importing.ImporterExampleFile object>]
classmethod get_example_file_content(example_file, request)[source]

Returns a binary file that will be served through the request. This base implementation just renders a template and returns the result as BytesIO or StringIO. Override this method to return a custom file content.

:param request HttpRequest :rtype StringIO|BytesIO

get_row_model(row)[source]

Get model that matches the row.

Can be used in cases where you have multiple types of data in same import.

Parameters:

row – A row dict.

identifier = 'company_importer'
meta_base_class

alias of AddressHandlerMeta

model

alias of Contact

name = 'Company Contact Importer'
class shuup.default_importer.importers.ProductImporter(data, context)[source]

Bases: DataImporter

example_files = [<shuup.importer.importing.importing.ImporterExampleFile object>, <shuup.importer.importing.importing.ImporterExampleFile object>, <shuup.importer.importing.importing.ImporterExampleFile object>, <shuup.importer.importing.importing.ImporterExampleFile object>, <shuup.importer.importing.importing.ImporterExampleFile object>, <shuup.importer.importing.importing.ImporterExampleFile object>]
classmethod get_example_file_content(example_file, request)[source]

Returns a binary file that will be served through the request. This base implementation just renders a template and returns the result as BytesIO or StringIO. Override this method to return a custom file content.

:param request HttpRequest :rtype StringIO|BytesIO

classmethod get_help_context_data(request)[source]

Returns the context data that should be used for help texts in admin.

help_template = 'shuup/default_importers/product_help.jinja'
identifier = 'product_importer'
meta_base_class

alias of ProductMetaBase

model

alias of Product

name = 'Product Importer'
relation_field = 'product'