SlideShare uma empresa Scribd logo
1 de 32
Baixar para ler offline
Using the new Import Module
How to use Magentos new ImportExport module in your custom modules

Imagine Conference, Feb. 2011 | Author: Vinai Kopp <vinai@netzarbeiter.com>
It's me!
Vinai Kopp


Magento Development since March 08
Magento Developer Training
Magento Consulting
Introducing the Players




 Overview of the the classes used during the import process
The Controller



 Mage_ImportExport_Adminhtml_ImportController

 Purpose: Entry Point
 Instantiates the Import Model and start Process
The Import Model




Mage_ImportExport_Model_Import

Purpose: Facade to the underlying import classes
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
The Source Adapter



Mage_ImportExport_Model_Import_Adapter_Csv

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




Mage_ImportExport_Model_Mysql4_Import_Data

Purpose: Interface to the import data table
Product Type Import Models




Mage_ImportExport_Model_Import_Entity_Product_Type_*

Purpose: Build and execute product type specific SQL
The Import Process

                                                          Temporary Table




        POINT OF ENTRY

           Adminhtml               IMPORT MODEL:       ENTITY TYPE ADAPTER
            Interface               validateSource()

                         Magento
  CLI
                         CronJob
                                                       DATA ARRAY



                                   SOURCE ADAPTER
                                                        Document
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
How can I use that?



 Import, Update or Delete Products and/or Customers
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
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_position

color                    news_from_dat       min_qty                       _links_upsell_sku

cost                     news_to_date        use_config_min_qty            _links_upsell_position

created_at               options_container   is_qty_decimal                _associated_sku

custom_design            page_layout         backorders                    _associated_default_qty

custom_design_from       price               use_config_backorders         _associated_position

custom_design_to         required_options    min_sale_qty                  _tier_price_website

custom_layout_update     short_description   use_config_min_sale_qty       _tier_price_customer_group

description              small_image         max_sale_qty                  _tier_price_qty

enable_googlecheckout    small_image_label   use_config_max_sale_qty       _tier_price_price

gallery                  special_from_date   is_in_stock                   _super_products_sku

gift_message_available   special_price       notify_stock_qty              _super_attribute_code

has_options              special_to_date     use_config_notify_stock_qty   _super_attribute_option

image                    status              manage_stock                  _super_attribute_price_corr

image_label              tax_class_id        use_config_manage_stock

is_imported              thumbnail           use_config_qty_increments

manufacturer             thumbnail_label     qty_increments
Cronjob Catalog Updates




Step One: Build Source Adapter for custom CSV file

Step Two: Create Cron Observer
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
Mage/ImportExport/Model/Import/Adapter/Custom.php
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
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
The Source Array 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_position

color                    news_from_dat       min_qty                       _links_upsell_sku

cost                     news_to_date        use_config_min_qty            _links_upsell_position

created_at               options_container   is_qty_decimal                _associated_sku

custom_design            page_layout         backorders                    _associated_default_qty

custom_design_from       price               use_config_backorders         _associated_position

custom_design_to         required_options    min_sale_qty                  _tier_price_website

custom_layout_update     short_description   use_config_min_sale_qty       _tier_price_customer_group

description              small_image         max_sale_qty                  _tier_price_qty

enable_googlecheckout    small_image_label   use_config_max_sale_qty       _tier_price_price

gallery                  special_from_date   is_in_stock                   _super_products_sku

gift_message_available   special_price       notify_stock_qty              _super_attribute_code

has_options              special_to_date     use_config_notify_stock_qty   _super_attribute_option

image                    status              manage_stock                  _super_attribute_price_corr

image_label              tax_class_id        use_config_manage_stock

is_imported              thumbnail           use_config_qty_increments

manufacturer             thumbnail_label     qty_increments
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,,,
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,,,
Product Import Source Array

  Configurable Products


One 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,,,
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
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,,,
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
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

 The core CSV Adapter is a good implementation reference
Trigger Import
 Cron Observer which wrapps the Import Model calls to
 validateSource(), importSource() and invalidateIndex()
Trigger Import
 Cron Observer which wrapps the Import Model calls to
 validateSource(), importSource() and invalidateIndex()
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
Conclusion



Mage_ImportExport fills an important gap!

Usable with technical knowledge because of the complex array
format

Couple of smallish bugs, but it's going places :]
Links



Sample Code: http://bit.ly/haCGWI

PDF of the Slides: http://bit.ly/i0eiI7

uRapidFlow: http://www.unirgy.com/products/urapidflow/
/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!

Mais conteúdo relacionado

Destaque

Magento Imagine eCommerce, Day 1, Roy Rubin Co-Founder & CEO
Magento Imagine eCommerce, Day 1, Roy Rubin Co-Founder & CEOMagento Imagine eCommerce, Day 1, Roy Rubin Co-Founder & CEO
Magento Imagine eCommerce, Day 1, Roy Rubin Co-Founder & CEO
varien
 
Magento Imagine Conference: With Friends Like These Who Needs Revenue?
Magento Imagine Conference: With Friends Like These Who Needs Revenue?Magento Imagine Conference: With Friends Like These Who Needs Revenue?
Magento Imagine Conference: With Friends Like These Who Needs Revenue?
varien
 
Best Practices for Launching an Enterprise Business on Magento
Best Practices for Launching an Enterprise Business on MagentoBest Practices for Launching an Enterprise Business on Magento
Best Practices for Launching an Enterprise Business on Magento
varien
 
Driving Business Innovation with Magento
Driving Business Innovation with MagentoDriving Business Innovation with Magento
Driving Business Innovation with Magento
varien
 
Optimizing Magento Performance with Zend Server
Optimizing Magento Performance with Zend ServerOptimizing Magento Performance with Zend Server
Optimizing Magento Performance with Zend Server
varien
 

Destaque (6)

Magento Imagine eCommerce, Day 1, Roy Rubin Co-Founder & CEO
Magento Imagine eCommerce, Day 1, Roy Rubin Co-Founder & CEOMagento Imagine eCommerce, Day 1, Roy Rubin Co-Founder & CEO
Magento Imagine eCommerce, Day 1, Roy Rubin Co-Founder & CEO
 
Magento Imagine Conference: With Friends Like These Who Needs Revenue?
Magento Imagine Conference: With Friends Like These Who Needs Revenue?Magento Imagine Conference: With Friends Like These Who Needs Revenue?
Magento Imagine Conference: With Friends Like These Who Needs Revenue?
 
Magento Imagine eCommerce, Day 2, Yoav Kutner CTO
Magento Imagine eCommerce, Day 2, Yoav Kutner CTOMagento Imagine eCommerce, Day 2, Yoav Kutner CTO
Magento Imagine eCommerce, Day 2, Yoav Kutner CTO
 
Best Practices for Launching an Enterprise Business on Magento
Best Practices for Launching an Enterprise Business on MagentoBest Practices for Launching an Enterprise Business on Magento
Best Practices for Launching an Enterprise Business on Magento
 
Driving Business Innovation with Magento
Driving Business Innovation with MagentoDriving Business Innovation with Magento
Driving Business Innovation with Magento
 
Optimizing Magento Performance with Zend Server
Optimizing Magento Performance with Zend ServerOptimizing Magento Performance with Zend Server
Optimizing Magento Performance with Zend Server
 

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

07. feeds update
07. feeds update07. feeds update
07. feeds update
marcwan
 
Gail villanueva add muscle to your wordpress site
Gail villanueva   add muscle to your wordpress siteGail villanueva   add muscle to your wordpress site
Gail villanueva add muscle to your wordpress site
references
 

Semelhante a Magento Imagine eCommerce Conference 2011: Using Magento's Import Module (20)

How to Create Module to Track Affiliate Conversions?
How to Create Module to Track Affiliate Conversions?How to Create Module to Track Affiliate Conversions?
How to Create Module to Track Affiliate Conversions?
 
Magento Indexes
Magento IndexesMagento Indexes
Magento Indexes
 
E-Bazaar
E-BazaarE-Bazaar
E-Bazaar
 
WordCamp Praga 2015
WordCamp Praga 2015WordCamp Praga 2015
WordCamp Praga 2015
 
How to Super Create Write Functions in Odoo 17
How to Super Create Write Functions in Odoo 17How to Super Create Write Functions in Odoo 17
How to Super Create Write Functions in Odoo 17
 
10 useful WordPress functions (and maybe more)
10 useful WordPress functions (and maybe more)10 useful WordPress functions (and maybe more)
10 useful WordPress functions (and maybe more)
 
07. feeds update
07. feeds update07. feeds update
07. feeds update
 
EVOLVE'13 | Enhance | Ecommerce Framework | Paolo Mottadelli
EVOLVE'13 | Enhance | Ecommerce Framework | Paolo MottadelliEVOLVE'13 | Enhance | Ecommerce Framework | Paolo Mottadelli
EVOLVE'13 | Enhance | Ecommerce Framework | Paolo Mottadelli
 
Evolve13 cq-commerce-framework
Evolve13 cq-commerce-frameworkEvolve13 cq-commerce-framework
Evolve13 cq-commerce-framework
 
Solid angular
Solid angularSolid angular
Solid angular
 
Utilization of zend an ultimate alternate for intense data processing
Utilization of zend  an ultimate alternate for intense data processingUtilization of zend  an ultimate alternate for intense data processing
Utilization of zend an ultimate alternate for intense data processing
 
Curso Symfony - Clase 3
Curso Symfony - Clase 3Curso Symfony - Clase 3
Curso Symfony - Clase 3
 
Building Potent WordPress Websites
Building Potent WordPress WebsitesBuilding Potent WordPress Websites
Building Potent WordPress Websites
 
WooCommerce CRUD and Data Store by Akeda Bagus
WooCommerce CRUD and Data Store by Akeda BagusWooCommerce CRUD and Data Store by Akeda Bagus
WooCommerce CRUD and Data Store by Akeda Bagus
 
Subscribed zuora forsalesforce training -section301-final
Subscribed zuora forsalesforce training -section301-finalSubscribed zuora forsalesforce training -section301-final
Subscribed zuora forsalesforce training -section301-final
 
Gail villanueva add muscle to your wordpress site
Gail villanueva   add muscle to your wordpress siteGail villanueva   add muscle to your wordpress site
Gail villanueva add muscle to your wordpress site
 
WebClient Customization.pdf
WebClient Customization.pdfWebClient Customization.pdf
WebClient Customization.pdf
 
Empowering users: modifying the admin experience
Empowering users: modifying the admin experienceEmpowering users: modifying the admin experience
Empowering users: modifying the admin experience
 
Rails Plugins - Linux For You, March 2011 Issue
Rails Plugins - Linux For You, March 2011 IssueRails Plugins - Linux For You, March 2011 Issue
Rails Plugins - Linux For You, March 2011 Issue
 
Optimization in django orm
Optimization in django ormOptimization in django orm
Optimization in django orm
 

Mais de varien

Magento's Imagine eCommerce Conference: Do You Queue?
Magento's Imagine eCommerce Conference: Do You Queue?Magento's Imagine eCommerce Conference: Do You Queue?
Magento's Imagine eCommerce Conference: Do You Queue?
varien
 
Magento Imagine eCommerce Conference:5 Way to Supercharge your Magento Enterp...
Magento Imagine eCommerce Conference:5 Way to Supercharge your Magento Enterp...Magento Imagine eCommerce Conference:5 Way to Supercharge your Magento Enterp...
Magento Imagine eCommerce Conference:5 Way to Supercharge your Magento Enterp...
varien
 
Getting from Here to There: How to assess your business, define an overall eC...
Getting from Here to There: How to assess your business, define an overall eC...Getting from Here to There: How to assess your business, define an overall eC...
Getting from Here to There: How to assess your business, define an overall eC...
varien
 
Selecting the 'Right' eCommerce Plaform
Selecting the 'Right' eCommerce PlaformSelecting the 'Right' eCommerce Plaform
Selecting the 'Right' eCommerce Plaform
varien
 

Mais de varien (12)

Magento's Imagine eCommerce Conference: Do You Queue?
Magento's Imagine eCommerce Conference: Do You Queue?Magento's Imagine eCommerce Conference: Do You Queue?
Magento's Imagine eCommerce Conference: Do You Queue?
 
Magento Imagine eCommerce Conference:5 Way to Supercharge your Magento Enterp...
Magento Imagine eCommerce Conference:5 Way to Supercharge your Magento Enterp...Magento Imagine eCommerce Conference:5 Way to Supercharge your Magento Enterp...
Magento Imagine eCommerce Conference:5 Way to Supercharge your Magento Enterp...
 
Magento Imgine eCommerce Conference February 2011: Mashup of Magento and Sale...
Magento Imgine eCommerce Conference February 2011: Mashup of Magento and Sale...Magento Imgine eCommerce Conference February 2011: Mashup of Magento and Sale...
Magento Imgine eCommerce Conference February 2011: Mashup of Magento and Sale...
 
Best Practices for Magento Debugging
Best Practices for Magento Debugging Best Practices for Magento Debugging
Best Practices for Magento Debugging
 
Getting from Here to There: How to assess your business, define an overall eC...
Getting from Here to There: How to assess your business, define an overall eC...Getting from Here to There: How to assess your business, define an overall eC...
Getting from Here to There: How to assess your business, define an overall eC...
 
Magento Roy Rubin Amsterdam Presentation
Magento Roy Rubin Amsterdam PresentationMagento Roy Rubin Amsterdam Presentation
Magento Roy Rubin Amsterdam Presentation
 
Maximizing Magento: Getting the Most out of Multi-Store Management
Maximizing Magento: Getting the Most out of Multi-Store ManagementMaximizing Magento: Getting the Most out of Multi-Store Management
Maximizing Magento: Getting the Most out of Multi-Store Management
 
Maximizing Magento: Getting the Most out of Promotions
Maximizing Magento: Getting the Most out of PromotionsMaximizing Magento: Getting the Most out of Promotions
Maximizing Magento: Getting the Most out of Promotions
 
Vortrag über Magento auf der InternetWorld 2008
Vortrag über Magento auf der InternetWorld 2008Vortrag über Magento auf der InternetWorld 2008
Vortrag über Magento auf der InternetWorld 2008
 
Selecting the 'Right' eCommerce Plaform
Selecting the 'Right' eCommerce PlaformSelecting the 'Right' eCommerce Plaform
Selecting the 'Right' eCommerce Plaform
 
Magento eCommerce And The Next Generation Of PHP
Magento eCommerce And The Next Generation Of PHPMagento eCommerce And The Next Generation Of PHP
Magento eCommerce And The Next Generation Of PHP
 
Under the Radar Magento Presentation
Under the Radar Magento PresentationUnder the Radar Magento Presentation
Under the Radar Magento Presentation
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 

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

  • 1. Using the new Import Module How to use Magentos new ImportExport module in your custom modules Imagine Conference, Feb. 2011 | Author: Vinai Kopp <vinai@netzarbeiter.com>
  • 2. It's me! Vinai Kopp Magento Development since March 08 Magento Developer Training Magento 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 Model Mage_ImportExport_Model_Import Purpose: 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 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 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_position color news_from_dat min_qty _links_upsell_sku cost news_to_date use_config_min_qty _links_upsell_position created_at options_container is_qty_decimal _associated_sku custom_design page_layout backorders _associated_default_qty custom_design_from price use_config_backorders _associated_position custom_design_to required_options min_sale_qty _tier_price_website custom_layout_update short_description use_config_min_sale_qty _tier_price_customer_group description small_image max_sale_qty _tier_price_qty enable_googlecheckout small_image_label use_config_max_sale_qty _tier_price_price gallery special_from_date is_in_stock _super_products_sku gift_message_available special_price notify_stock_qty _super_attribute_code has_options special_to_date use_config_notify_stock_qty _super_attribute_option image status manage_stock _super_attribute_price_corr image_label tax_class_id use_config_manage_stock is_imported thumbnail use_config_qty_increments manufacturer thumbnail_label qty_increments
  • 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 Mage/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 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_position color news_from_dat min_qty _links_upsell_sku cost news_to_date use_config_min_qty _links_upsell_position created_at options_container is_qty_decimal _associated_sku custom_design page_layout backorders _associated_default_qty custom_design_from price use_config_backorders _associated_position custom_design_to required_options min_sale_qty _tier_price_website custom_layout_update short_description use_config_min_sale_qty _tier_price_customer_group description small_image max_sale_qty _tier_price_qty enable_googlecheckout small_image_label use_config_max_sale_qty _tier_price_price gallery special_from_date is_in_stock _super_products_sku gift_message_available special_price notify_stock_qty _super_attribute_code has_options special_to_date use_config_notify_stock_qty _super_attribute_option image status manage_stock _super_attribute_price_corr image_label tax_class_id use_config_manage_stock is_imported thumbnail use_config_qty_increments manufacturer 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 Products One 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 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 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. Conclusion Mage_ImportExport fills an important gap! Usable with technical knowledge because of the complex array format Couple of smallish bugs, but it's going places :]
  • 31. Links Sample Code: http://bit.ly/haCGWI PDF of the Slides: http://bit.ly/i0eiI7 uRapidFlow: 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!