In some cases the items being imported may be conglomerated (as in an XML feed, where a single retrieval contains many items). In these cases, MigrateSourceMultiItems may be the right choice to represent the source data.
The subordinate MigrateItems class operates much like a fusion of MigrateList and MigrateItem. To define a MigrateItems class for a particular type of source, you need to implement the following methods:
__toString()
Should return a string representing the source of the ID (e.g., the URL of an XML feed).
getIdList()
Should return an array of the IDs available from the source.
computeCount()
Should return a count of the IDs available from the source.
getItem($id)
Given an ID obtained getIdList(), returns the data for the source item keyed by that ID, as an object.
MigrateSourceMultiItems
The MigrateSourceMultiItems class wraps around your MigrateItems object. In your migration constructor, construct a MigrateItems instance, and pass it the MigrateSourceList constructor (you may optionally also pass a source field list and an options array). The MigrateSourceMultiItems instance you create will then iterate over the IDs returned by getIdList(), passing each one to getItem() to obtain source data to be migrated.
See XML-based sources for an example of using these classes in your migration.
Comments
Paragraph needs rewriting
The final paragraph on this page under subhead "MigrateSourceMultiItems" is unclear:
What does "wraps around" mean?
What does it mean to "pass the MigrateSourceList constructor" to a MigrateItems instance? How do you "pass" a constructor to an instance of some other class? And does this mean a MigrateItems and MigrateSourceList object are both necessary to create a MigrateSourceMultiItems instance?
When does this iteration happen? Upon construction of the MigrateSourceMultiItems instance, or during the actual migration?
----------------
Customer Support Engineer, Granicus
https://granicus.com
no getIdList() method
This class does not appear to have a getIdList() function as indicated above. When I try to call it on an instance of the class, I get
You can, however, call getIdList on the MigrateItemsXML object that you use as a parameter when instantiating this class.