Extend the module
This page is for the PHP developer who needs a feed to do something the admin cannot set up: a platform the module does not know, a value worked out by your own code, a file format or a destination of your own. Each extension point is a di.xml item or an XML file in a module of yours; nothing in the Arlanix modules is edited.
Where each one runs
A feed's rows go through these steps, in this order:
- Row transformers change, leave out or split the product rows as they are read. See Row transformers.
- The mapping fills each field of a row from its source: an attribute, a resolver or a template. Modifiers inside a template placeholder run here.
- A dictionary, when the row names one, translates the value.
- The mapping row's modifiers change the value after the dictionary.
- A writer writes the rows as a file, for a channel that publishes a file.
- A channel delivers the file, or hands batches of rows to a push adapter.
The field catalog of the feed's type sits beside all of this: it gives Copy from the platform's fields and their defaults, and warns when a mapped value breaks a catalog rule.
Choose an extension point
| You want | Use | Page |
|---|---|---|
| A platform the module does not list, or a change to a field of one it does | A field catalog in etc/feed_catalog.xml |
Field catalogs |
| A value no attribute holds, worked out per product | A resolver, in Resolver\Pool |
Resolvers |
| A change to a value that a modifier chip can apply on any row | A modifier, in ModifierPool |
Modifiers |
| A file format other than CSV, TSV, XML, JSON and JSON Lines | A writer, in WriterPool |
Writers |
| A destination other than the store and SFTP, or a platform API | A channel, in Channel\ChannelPool |
Channels |
| One row per pack size, a price from your ERP, a product one market must not see | A row transformer, in RowTransformerPool |
Row transformers |
What every extension point has in common
Your module declares the Arlanix module it extends in its etc/module.xml, so its di.xml and feed_catalog.xml are read after the Arlanix ones:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vendor_Module">
<sequence>
<module name="Arlanix_ProductFeed"/>
</sequence>
</module>
</config>
Resolver\Pool, Channel\ChannelPool, RowTransformerPool and etc/feed_catalog.xml belong to Arlanix_ProductFeed; WriterPool and ModifierPool belong to Arlanix_Core, which Arlanix_ProductFeed depends on.
Each pool takes its members by name in di.xml. A feed stores its resolver, modifier, format and channel names. Keep those names once a store uses them. A row transformer applies to the feeds its appliesTo() method selects.
Each pool checks its members when Magento constructs it. An unknown resolver, modifier or file format fails the run. Cron skips a feed whose channel type is missing.
After adding or changing an item, run the following in the Magento root:
bin/magento setup:upgrade
bin/magento cache:clean config
In production mode, also run bin/magento setup:di:compile.
If the extension changes mapped rows, save each affected Merchant API feed after deployment. This queues a full catalogue pass so the feed also remaps products that have not changed. See Merchant API feeds.