Your SlideShare is downloading. ×
  • Like
Magento Imagine eCommerce Conference 2011: Using Magento's Import Module
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Magento Imagine eCommerce Conference 2011: Using Magento's Import Module

  • 1,934 views
Published

 

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,934
On SlideShare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
22
Comments
0
Likes
2

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Using the new Import ModuleHow to use Magentos new ImportExport module in your custom modulesImagine Conference, Feb. 2011 | Author: Vinai Kopp <vinai@netzarbeiter.com>
  • 2. Its me!Vinai KoppMagento Development since March 08Magento Developer TrainingMagento Consulting
  • 3. Introducing the Players Overview of the the classes used during the import process
  • 4. The Controller Mage_ImportExport_Adminhtml_ImportController Purpose: Entry Point Instantiates the Import Model and start Process
  • 5. The Import ModelMage_ImportExport_Model_ImportPurpose: Facade to the underlying import classes
  • 6. The Entity Type Model Mage_ImportExport_Model_Import_Entity_Product Mage_ImportExport_Model_Import_Entity_Customer Purpose: Build and execute SQL for imports, updates and deletes
  • 7. The Source AdapterMage_ImportExport_Model_Import_Adapter_CsvPurpose: Parse and access input data into arrays as expected by theentity type model
  • 8. Import Data Resource ModelMage_ImportExport_Model_Mysql4_Import_DataPurpose: Interface to the import data table
  • 9. Product Type Import ModelsMage_ImportExport_Model_Import_Entity_Product_Type_*Purpose: Build and execute product type specific SQL
  • 10. The Import Process Temporary Table POINT OF ENTRY Adminhtml IMPORT MODEL: ENTITY TYPE ADAPTER Interface validateSource() Magento CLI CronJob DATA ARRAY SOURCE ADAPTER Document
  • 11. The Import Process POINT OF ENTRY Adminhtml Interface Magento CLI CronJob Temporary Table IMPORT MODEL: ENTITY TYPE ADAPTER importSource() CATALOG SQL TABLE PRODUCT TYPE IMPORT MODEL
  • 12. How can I use that? Import, Update or Delete Products and/or Customers
  • 13. How can I use that? Example: Cronjob catalog updates via custom CSV files Custom CSV Fields:sku, name, description, short_description, store_id, websites, weight, price, qty, color
  • 14. Why a custom CSV file format?sku media_gallery updated_at use_config_enable_qty_increments_store meta_description url_key enable_qty_increments_attribute_set meta_keyword url_path _links_related_sku_type meta_title visibility _links_related_position_category minimal_price weight _links_crosssell_sku_product_websites name qty _links_crosssell_positioncolor news_from_dat min_qty _links_upsell_skucost news_to_date use_config_min_qty _links_upsell_positioncreated_at options_container is_qty_decimal _associated_skucustom_design page_layout backorders _associated_default_qtycustom_design_from price use_config_backorders _associated_positioncustom_design_to required_options min_sale_qty _tier_price_websitecustom_layout_update short_description use_config_min_sale_qty _tier_price_customer_groupdescription small_image max_sale_qty _tier_price_qtyenable_googlecheckout small_image_label use_config_max_sale_qty _tier_price_pricegallery special_from_date is_in_stock _super_products_skugift_message_available special_price notify_stock_qty _super_attribute_codehas_options special_to_date use_config_notify_stock_qty _super_attribute_optionimage status manage_stock _super_attribute_price_corrimage_label tax_class_id use_config_manage_stockis_imported thumbnail use_config_qty_incrementsmanufacturer thumbnail_label qty_increments
  • 15. Cronjob Catalog UpdatesStep One: Build Source Adapter for custom CSV fileStep Two: Create Cron Observer
  • 16. Specify a Custom Source AdapterThe Source Adapter Class is specified by the File ExtensionMage_ImportExport_Model_Import_Adapter_ . $type;sourcefile.csv.custom to use Source AdapterMage/ImportExport/Model/Import/Adapter/Custom.php
  • 17. The Source Adapter Interface Extend Mage_ImportExport_Model_Import_Adapter_Abstract Implements SeekableIterator Interface Create rewind(), next() and seek() methods using _init() to setup data
  • 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 Formatsku media_gallery updated_at use_config_enable_qty_increments_store meta_description url_key enable_qty_increments_attribute_set meta_keyword url_path _links_related_sku_type meta_title visibility _links_related_position_category minimal_price weight _links_crosssell_sku_product_websites name qty _links_crosssell_positioncolor news_from_dat min_qty _links_upsell_skucost news_to_date use_config_min_qty _links_upsell_positioncreated_at options_container is_qty_decimal _associated_skucustom_design page_layout backorders _associated_default_qtycustom_design_from price use_config_backorders _associated_positioncustom_design_to required_options min_sale_qty _tier_price_websitecustom_layout_update short_description use_config_min_sale_qty _tier_price_customer_groupdescription small_image max_sale_qty _tier_price_qtyenable_googlecheckout small_image_label use_config_max_sale_qty _tier_price_pricegallery special_from_date is_in_stock _super_products_skugift_message_available special_price notify_stock_qty _super_attribute_codehas_options special_to_date use_config_notify_stock_qty _super_attribute_optionimage status manage_stock _super_attribute_price_corrimage_label tax_class_id use_config_manage_stockis_imported thumbnail use_config_qty_incrementsmanufacturer thumbnail_label qty_increments
  • 20. Product Import Source Array Configurable Products _super_products_sku _super_attribute_code _super_attribute_option _super_attribute_price_corr... 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,,,
  • 21. Product Import Source Array Configurable Products One row for every associated simple product in addition to record for the simple product itself _super_products_sku... 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,,,
  • 22. Product Import Source Array Configurable ProductsOne row for every associated simple product attribute _super_attribute_code... 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,,,
  • 23. Product Import Source Array Configurable Products One row for every attribute with a price update _super_products_price_corr... 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
  • 24. Product Import Source Array Configurable Products _super_products_sku and _super_attribute_option do not (have to) correspond... 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,,,
  • 25. Product Import Source ArrayCustom 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 SourceAdapter 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 The core CSV Adapter is a good implementation reference
  • 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. ConclusionMage_ImportExport fills an important gap!Usable with technical knowledge because of the complex arrayformatCouple of smallish bugs, but its going places :]
  • 31. LinksSample Code: http://bit.ly/haCGWIPDF of the Slides: http://bit.ly/i0eiI7uRapidFlow: http://www.unirgy.com/products/urapidflow/
  • 32. /me is happy to hear from you vinai@netzarbeiter.com :: @VinaiKopp Thank you @riconeitzel for all the time and for making this look good! Thanks to Magento!