• No results found

Using the new Import Module

N/A
N/A
Protected

Academic year: 2021

Share "Using the new Import Module"

Copied!
32
0
0

Loading.... (view fulltext now)

Full text

(1)

Imagine Conference, Feb. 2011 | Author: Vinai Kopp <[email protected]>

Using the new Import Module

(2)

It's me!

Vinai Kopp

Magento Development since March 08 Magento Developer Training

(3)

Introducing the Players

(4)

The Controller

Mage_ImportExport_Adminhtml_ImportController Purpose: Entry Point

(5)

The Import Model

Mage_ImportExport_Model_Import

(6)

The Entity Type Model

Mage_ImportExport_Model_Import_Entity_Product Mage_ImportExport_Model_Import_Entity_Customer

(7)

The Source Adapter

Mage_ImportExport_Model_Import_Adapter_Csv

Purpose: Parse and access input data into arrays as expected by the entity type model

(8)

Import Data Resource Model

Mage_ImportExport_Model_Mysql4_Import_Data Purpose: Interface to the import data table

(9)

Product Type Import Models

Mage_ImportExport_Model_Import_Entity_Product_Type_* Purpose: Build and execute product type specific SQL

(10)

The Import Process

POINT OF ENTRY Magento CronJob CLI Adminhtml Interface IMPORT MODEL: validateSource() SOURCE ADAPTER

ENTITY TYPE ADAPTER

Document

DATA ARRAY

(11)

The Import Process

POINT OF ENTRY Magento CronJob CLI Adminhtml Interface

ENTITY TYPE ADAPTER

Temporary Table IMPORT MODEL: importSource() SQL PRODUCT TYPE IMPORT MODEL CATALOG TABLE

(12)

How can I use that?

(13)

How can I use that?

Example: Cronjob catalog updates via custom CSV files Custom CSV Fields:

(14)

Why a custom CSV file format?

sku _store _attribute_set _type _category _product_websites color cost created_at custom_design custom_design_from custom_design_to custom_layout_update description enable_googlecheckout gallery gift_message_available has_options image image_label is_imported manufacturer media_gallery meta_description meta_keyword meta_title minimal_price name news_from_dat news_to_date options_container page_layout price required_options short_description small_image small_image_label special_from_date special_price special_to_date status tax_class_id thumbnail thumbnail_label updated_at url_key url_path visibility weight qty min_qty use_config_min_qty is_qty_decimal backorders use_config_backorders min_sale_qty use_config_min_sale_qty max_sale_qty use_config_max_sale_qty is_in_stock notify_stock_qty use_config_notify_stock_qty manage_stock use_config_manage_stock use_config_qty_increments qty_increments use_config_enable_qty_increments enable_qty_increments _links_related_sku _links_related_position _links_crosssell_sku _links_crosssell_position _links_upsell_sku _links_upsell_position _associated_sku _associated_default_qty _associated_position _tier_price_website _tier_price_customer_group _tier_price_qty _tier_price_price _super_products_sku _super_attribute_code _super_attribute_option _super_attribute_price_corr

(15)

Cronjob Catalog Updates

Step One: Build Source Adapter for custom CSV file Step Two: Create Cron Observer

(16)

Specify a Custom Source Adapter

The Source Adapter Class is specified by the File Extension Mage_ImportExport_Model_Import_Adapter_ . $type;

sourcefile.csv.custom to use Source Adapter

(17)

The Source Adapter Interface

Extend Mage_ImportExport_Model_Import_Adapter_Abstract Implements SeekableIterator Interface

(18)

The Source Adapter Interface

protected function _init()

Read source and build the same data structure like the core csv adapter

The source array format can best be referenced by exporting some products and looking at the first line in the resulting export file

(19)

The Source Array Format

sku _store _attribute_set _type _category _product_websites color cost created_at custom_design custom_design_from custom_design_to custom_layout_update description enable_googlecheckout gallery gift_message_available has_options image image_label is_imported manufacturer media_gallery meta_description meta_keyword meta_title minimal_price name news_from_dat news_to_date options_container page_layout price required_options short_description small_image small_image_label special_from_date special_price special_to_date status tax_class_id thumbnail thumbnail_label updated_at url_key url_path visibility weight qty min_qty use_config_min_qty is_qty_decimal backorders use_config_backorders min_sale_qty use_config_min_sale_qty max_sale_qty use_config_max_sale_qty is_in_stock notify_stock_qty use_config_notify_stock_qty manage_stock use_config_manage_stock use_config_qty_increments qty_increments use_config_enable_qty_increments enable_qty_increments _links_related_sku _links_related_position _links_crosssell_sku _links_crosssell_position _links_upsell_sku _links_upsell_position _associated_sku _associated_default_qty _associated_position _tier_price_website _tier_price_customer_group _tier_price_qty _tier_price_price _super_products_sku _super_attribute_code _super_attribute_option _super_attribute_price_corr

(20)

Product Import Source Array

Configurable Products ... 0,1,0.0000,1,1,,1,0,1,1,0.0000,1,0,,,,,,,,,,,,,,sku-Pear-Cyan,manufacturer,Pear,100.0000 ... ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,sku-Pear-Indigo,color,Cyan,5.0000 ... ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,sku-Pear-Mauve,,, ... ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,sku-Pear-Pink,,, ... ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,sku-Peach-Cyan,,, _super_products_sku _super_attribute_code _super_attribute_option _super_attribute_price_corr

(21)

Product Import Source Array

... 0,1,0.0000,1,1,,1,0,1,1,0.0000,1,0,,,,,,,,,,,,,,sku-Pear-Cyan,manufacturer,Pear,100.0000 ... ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,sku-Pear-Indigo,color,Cyan,5.0000 ... ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,sku-Pear-Mauve,,, ... ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,sku-Pear-Pink,,, ... ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,sku-Peach-Cyan,,, _super_products_sku One row for every associated simple product in

addition to record for the simple product itself Configurable Products

(22)

Product Import Source Array

... 0,1,0.0000,1,1,,1,0,1,1,0.0000,1,0,,,,,,,,,,,,,,sku-Pear-Cyan,manufacturer,Pear,100.0000 ... ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,sku-Pear-Indigo,color,Cyan,5.0000 ... ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,sku-Pear-Mauve,,, ... ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,sku-Pear-Pink,,, ... ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,sku-Peach-Cyan,,, _super_attribute_code One row for every associated simple product attribute

(23)

Product Import Source Array

... 0,1,0.0000,1,1,,1,0,1,1,0.0000,1,0,,,,,,,,,,,,,,sku-Pear-Cyan,manufacturer,Pear,100.0000 ... ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,sku-Pear-Indigo,color,Cyan,5.0000 ... ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,sku-Pear-Mauve,,, ... ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,sku-Pear-Pink,,, ... ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,sku-Peach-Cyan,,, _super_attribute_option

One row for every attribute with a price update _super_products_price_corr

(24)

Product Import Source Array

... 0,1,0.0000,1,1,,1,0,1,1,0.0000,1,0,,,,,,,,,,,,,,sku-Pear-Cyan,manufacturer,Pear,100.0000 ... ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,sku-Pear-Indigo,color,Cyan,5.0000 ... ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,sku-Pear-Mauve,,, ... ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,sku-Pear-Pink,,, ... ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,sku-Peach-Cyan,,,

_super_products_sku and _super_attribute_option do not (have to) correspond

(25)

Product Import Source Array

Custom Options _custom_option_store _custom_option_type _custom_option_title _custom_option_is_required _custom_option_price _custom_option_sku _custom_option_max_characters _custom_option_sort_order _custom_option_row_title _custom_option_row_price _custom_option_row_sku _custom_option_row_sort

(26)

Implementation of the Source

Adapter

Implement SeekableIterator Interface

seek(), current(), next(), rewind(), key(), valid()

All except next(), rewind() and seek() are implemented in the abstract class Mage_ImportExport_Model_Import_Adapter_Abstract

(27)

Trigger Import

Cron Observer which wrapps the Import Model calls to validateSource(), importSource() and invalidateIndex()

(28)

Trigger Import

Cron Observer which wrapps the Import Model calls to validateSource(), importSource() and invalidateIndex()

(29)

Other possibilities

Anything that gets product data into Magento in bulk operations, e.g. XML Files

REST Request with product data in payload Unix domain sockets

(30)

Conclusion

Mage_ImportExport fills an important gap!

Usable with technical knowledge because of the complex array format

(31)

Links

Sample Code: http://bit.ly/haCGWI PDF of the Slides: http://bit.ly/i0eiI7

(32)

/me is happy to hear from you

[email protected] :: @VinaiKopp

Thank you @riconeitzel for all the time and for making this look good! Thanks to Magento!

References

Related documents

functioning of a discussion; this only demonstrates that the number of questions asked and number of different kinds of questions are not the cause of productive whole-class

 The arrival rate pattern, discharge timing, and allocation delay. distribution determine the

Tasarım kalitesinin ürün ve süreç kalitesi olmak üzere iki boyutta incelenmesinin sonucunda ta- sarım kalitesini etkileyen faktörler; tasarım or- ganizasyonunda proje

CONTRIBUTION TO THE AQUATIC BEETLE FAUNA OF THE SOUTHERN PART OF TRANSDANUBIAN REGION, HUNGARY (COLEOPTERA: HYDRADEPHAGA, HYDROPHILOIDEA).. ABSTRACT: Altogether 491 new

classroom practice also reflected that there are language text books in schools that talk to the activities that are to be performed by learners in order to implement both

The present study investigated interactions between the novel psychoactive tryptamines DiPT, 4-OH-DiPT, 4-OH-MET, 5-MeO-AMT, and 5-MeO-MiPT at monoamine receptors

The XTEAM environment allows an architect to extend the ACT by defining new elements, attributes, and constraints that (1) tailor the model to a specific component technology, such

• If proof of purchase is not available or the product is out of the warranty period, a replacement part can be purchased.. • If it has a crack or leak and has been reported