How to use Data Feed Manager?
STEP 1: Configure Data Feed Manager in a general way
Before being able to configure your data feeds, you need to configure the extension in a general way. To do so, go to:
Stores Settings Configuration Wyomind Data Feed Manager
Cron job reporting
In the Cron job reporting tab, you can activate the cron job reporting and fill in one or more email addresses to receive the reports. You have also the possibility to define a sender as well as to rename the reports as you want.
Core Settings
In the Core Settings tab, you'll need to configure a certain number of fields.
- Items in preview
By default, there are 10 items in preview, if you want you can reduce or increase that number. - Items in buffer
By default, products are inserted into the file on the server every 10 items but you can reduce or increase that number. - Items in SQL request
By default, there are 1500 items in each MySql query. - Number of advanced filters
By default, you have 10 advanced filters. If you need more, you can at any time increase that value. - Use of OR/AND statements in advanced filters
OR/AND statements can be used in the advanced filters simply by enabling that option. - Include not in menu categories
You can also include the categories of products that are not in the menu. - Memory limit size (M)
The default memory limit is 1024. - Use canonical urls
You have the choice between several options. You can choose to use the shortest category URL, the longest one, or the product URL. - Enable log reporting
You can also enable the log reporting. - Allow trans-domain import/export
Allow import and export options. - Include disabled products
You can choose to include disabled products in the data feed.
STEP 2: Configure your data feeds with Data Feed Manager
To create and configure your data feeds, go to:
ProductsData Feed Manager Data Feeds
Your data feeds will be listed according to IDs. For each data feed pattern, you will find the name of the file, its path as well as the link to the data feed file.
The status of your data feed can be:
- Pending: the data feed has never been generated or the scheduled hour is passed (waiting for the execution from the cron task)
- Success: successful generation of the data feed, manually or automatically (the generation corresponds with a schedule)
- Hold: in the process of generation (latency, indeterminate status)
- Processing: generation progression percentage
- Error: the generation is stopped
In the grid, you should find the date and the hour of the last time the data feed has been generated as well as the store view for which it has been saved.
From the Action dropdown, you'll be able to:
- Edit
- Generate
- Preview (10 products)
- Delete
The Tool Box
The Data Feed Manager extension includes a tool to help you create your feed and see what is wrong. When creating a data feed, you should see 2 buttons on the right of your screen.
The toolbox is inevitably very useful. This will help you to configure your data feed more quickly.
Below are the different options for the toolbox.
Preview
Library
If you click on that button, a library of your store attributes will be displayed. This makes it easier to find very quickly which attribute you need to add to your pattern.
Export and import your data feed templates
Data Feed Manager also allows you to import and export patterns into and from your Magento 2 admin.
Export
To export a data feed pattern, edit an existing feed from:
Products Data Feed ManagerData Feeds
Once the data feed configuration page is loaded, you will be able to click on Export.
A popup window opens and allows you to save the data feed pattern as a .dfm file (specific to Data Feed Manager). After that, you should find the data feed pattern in your Downloads folder.
Import
Before anything, to import a data feed pattern, it must be a .dfm file, which is specific to the Data Feed Manager extension.
Click on Import a data feed from:
Products Data Feed Manager Data Feeds
Browse the .dfm file and click on Import data feed.
The data feed pattern should have been added to the list of feeds.
Configuration
To create your own data feed, click on Create new data feed from:
Products Data Feed Manager Data Feeds
In that first tab is the main configuration of the data feed. To customize your data feed, you'll find several fields to fill in.
- Name
Enter a name for the file. - File Type
Choose the format of your file between XML, CSV, TXT, and TSV. - File name format
You have several format possibilities for your file name.
GoogleShopping-2015-01-26.xml - Encoding type
Choose the encoding type of the data feed. - Path
Define the path where you want the data feed to be generated.
/feeds/ - Status
Enable or disable the file. - Store View
Define which store view is concerned.
Note that you can also export the attributes default values.
The configuration of the data feed will vary depending on the File Type you've chosen.
XML FILES
- Enclose xml tag content inside CDATA (recommended)
Enclose XML tags inside CDATA or not. - Remove all empty xml tags (recommended)
Remove empty XML tags or not. - Header pattern
Add your header pattern in that field. - Product Pattern
This is probably the most important field as this is where you will configure your pattern. - Footer pattern
Here is the footer pattern.
CSV, TXT, TSV FILES
- Extra header
It will add whatever you write on the top of your file (fit in with Amazon requirements). - Include header
Allows you to include or not columns names in the first row of your file. - Columns name
Is for the attribute name (you need to look in the shopping engine specifications to know which names are required). - Pattern
Works in the same way as XML files. For example, {{product.url}} will return the product's URL. You can also add any static value. - Insert a new field
Click on it to add a new column to your pattern. The fields order can be easily reordered by using the up and down arrows. - Extra footer
You can add an extra footer in that field. - Fields delimiter
Lets you choose which kind of delimiter you want to use to separate your fields. - Fields enclosure
Lets you choose which kind of enclosure you want for your data. - Escape character
Define the escape character between or ".
Categories filter
You can filter your categories according to two different ways:
- Exclude all products from the selected categories.
- Include all products from the selected categories.
You also have different possibilities to filter your categories. You can include or exclude your categories depending on:
- Parent categories only
In the case where you have a configurable product with simple variants associated. The configurable has a category assigned but not the variants. - Product categories only
If you have categories assigned to simple variants but not to the configurable product. - Product and parent categories
In the case where you have both situations.
Category selection and mapping
In that subtab, you can select and map your categories to the ones of the marketplaces. This step is very important so that they can make a link between their product categories and yours.
With Data Feed Manager, you have the possibility to change the file on which the category mapping is based.
Taxonomy files for the main countries are directly included to allow you to map your categories more easily. You can also have a look at our documentation to know how to add a new taxonomy file and how to map your categories.
What is a category mapping?
Categories names you are using in your Magento 2 back-office aren't always the same than the ones used by the marketplaces to reference your products.
This means you have to find out which categories have the best matching with yours, according to the their product taxonomy.
For example, if you're selling furniture like coffee tables, you'll certainly have a Coffee table category in your Magento 2 back-office.
But Google Merchant doesn't handle this kind of category. The closest Google product category would be Kitchen & Dining Room Table. So this should appear this way in your data feed:
<g:google_product_category>Furniture > Desks & Tables > Kitchen & Dining Room Tables</g:google_product_category>
How to map your categories with Data Feed Manager?
Data Feed Manager provides you an easy way to input Google product categories matching yours.
In your data feed configuration, go to the Categories tab. Then, in the Category selection and mapping section, you'll find a tree view of all your categories.
For each category, you have a little arrow followed by mapped as.
There, you'll be able to start typing a keyword in order to display a list of all categories including that keyword. You simply need to select the one you need.
Once all your categories are mapped, you can click on the Save button.
Here are a few guidelines for choosing the most appropriate category:
- Use the category that best describes your item. To do this, first determine the primary function of the products you are submitting. For specific items like MP3 Players, select the MP3 Players category. While some MP3 players can also serve different functions, like those that contain a clock, they are primarily MP3 Players.
- Use only one category. For some products, more than one category might be relevant. For example, an adapter to allow an MP3 player to be used in a car could be in both categories Motor Vehicles > Audio & Video and Electronics > Audio > Audio Accessories > MP3 Player Accessories. In such cases, choose the category that seems the most appropriate to you, but don't include more than one.
- Use the most specific category possible. Being specific will help improve your data quality and in turn ensure that offers are presented in the right category. When viewing the taxonomy, try to navigate to the most specific category that still covers all the products being submitted. For instance, if you are submitting MP3 player chargers use the category MP3 Player Chargers. Conversely, if you are submitting multiple types of chargers use the category Chargers.
How to include the category to the XML template?
Finally, so that the category is retrieved in your data feed, you must add the following attribute to the XML template:
<category>{{product.category_mapping}}</category>
or for Google:
<g:google_product_category>{{product.category_mapping}}</g:google_product_category>
How to add a new taxonomy file in Data Feed Manager?
The product taxonomy is a tree of categories that will help you generate values for your own categories.
You can easily add a taxonomy file with Data Feed Manager.
For Google Shopping, choose the language you want to use for your taxonomy at the bottom right of that page. Then, in the Downloadable taxonomy, open the Plain Text link that contains full category names.
Save that file and paste it in:
Magento 2 Root DirectorylibWyomind
Don't forget to apply the permissions 644 to the file.
You'll then be able to choose that specific taxonomy from your data feed configuration.
Filters
Data Feed Manager allows you to filter your products on several levels.
Product Type
First of all, you can choose to include products to your feed according to their type. For example, only include simple, virtual, and downloadable products.
Attribute Set
Product Visibility
Then, choose the products that will be included in the feed between the products that are not visible individually, products from the Catalog, the Search results, or both.
Advanced Filters
In the Advanced filters, you can go further by setting more personalized filters.
For example, we wanted to include only products which price is higher than 0, and which SKU is not null.
Here again, you have the possibility to define advanced filters according to several options such as =, >, < or even more as shown below.
- LIKE / NOT LIKE
name like %shirt: will include all products which name ends with 'shirt'.
name like Apple%: will include all products which name starts with 'Apple'.
name like %women%: will include all products which name contains the 'women' character string
name not like %shirt: won't include any product which name ends with 'shirt'.
name not like Apple%: won't include any product which name starts with 'Apple'.
name not like %women%: won't include any product which name contains the 'women' character string.
- IS NULL / IS NOT NULL
Special price is null: will include all products that don't have special prices.
SKU is not null: will include all products which SKU is not null.
- IN / NOT IN
Size in S L: will include only products from these 2 sizes.
Size not in S L: will include all products which size is not S or L.
Cron schedule
Data Feed Manager for Magento 2 provides you with a fully configurable schedule in the Cron Schedule tab of each data feed configuration.
You simply have to tick the days and hours when you want your data feed to be generated.
If you're facing some difficulties with scheduled tasks, or if you think your data feed is not automatically generated, have a look to our faq on that subject.
FTP settings
With Data Feed Manager for Magento 2, you can specify FTP settings to upload your data feeds. In the FTP settings tab of your data feed, you'll have several fields to configure:
- Enable FTP upload
Select Yes if you want to upload your data feed using FTP - Use SFTP
Select Yes if you are using SFTP - Use Active mode
If you are using SFTP, you don't have to care about the passive/active mode - Host
In that field, fill in the host.
ftp.wyomind.com - Port
Fill in the port.
22 - Login
Is your login to connect to the server - Password
Is your password to connect to the server - Destination directory
Is a relative path from the entry directory when you connect to the FTP.
upload/
or
/
In order to be sure your settings are correct, you can click on Test Connection.
- If you don't have an error message, it means the connection succeeded.
- If you have an error message, you'll certainly have to check your credentials.
In the case where you don't get any error message while testing the connection, you'll need to check that the file is well uploaded.
STEP 3: Generate and download the data feeds
Generate the data feeds
With Data Feed Manager, you have the possibility to generate your data feed manually or automatically.
Manually
You can generate your data feeds manually in the grid from the action dropdown.
You can also do it from the configuration panel by clicking on Generate.
With the cron tasks
If not, you should see a warning message in Data Feed Manager.
You must have selected a least one day and one-time frame from the Scheduled tasks tab of each data feed that must be updated.
With the command lines
To generate all the data feeds:
bin/magento wyomind:datafeedmanager:generate
To generate one data feed from a given id:
bin/magento wyomind:datafeedmanager:generate int DATA_FEED_ID
To generate several data feeds from a given list of ids:
bin/magento wyomind:datafeedmanager:generate int DATA_FEED_ID [, int DATA_FEED_ID] [, int DATA_FEED_ID]...
To list all data feeds including status, name, last update:
bin/magento wyomind:datafeedmanager:list
Download the data feeds
When a data feed is ready to be downloaded, the link is displayed in both, the data feed grid and the data feed page at the top of the page. To download the data feed, right-click on the link and select Save link as. You can also find the file in your ftp client if the directory where the data feed is stored is not publicly accessible.
Manage your data feed templates with Data Feed Manager
10 Things to know when creating an XML data feed with Data Feed Manager
All the XML data feeds used by shopping engines, like the one used by Google Shopping, are really simple to build but often have their own specifications.
Simple Google Shopping and Data Feed Manager for Magento 2 provide one or more ready-to-configure patterns. These patterns will allow you to quickly build a valid and well-structured data feed.
- An XML data feed is using opening and closing tags that include a value.
<tag>value</tag>
- A data feed template is made up of several tags that include dynamic or fixed values.
<g:id>{{product.sku}}</g:id><g:brand>YOUR BRAND</g:brand>
- Dynamic values are called variables and use the attribute codes of your Magento website preceded with the object. The variable must be enclosed using double brackets as {{object.attribute}}.
<g:id>{{product.sku}}</g:id><price>{{parent.price}}</price>
- Between every opening and closing tags, you can also include some fixed values. Fixed values are simply text.
<g:brand>YOUR BRAND</g:brand>
- You have also the possibility to add several variables and fixed values in the same tag.
<title>{{parent.name}}, available in {{product.color}} for only ${{product.price}}</title>
- Some Magento 2 attributes like price, image or url may have further configuration options or parameters that will correspond to your specific data feed needs. For example:
<price>{{product.price currency=EUR vat_rate=20}}</price>
- You're allowed to use PHP code if you want to customize the pattern. For example, to retrieve the name of a product in lower cases:
<tag>{{product.name output="wyomind_strtolower($self)"}}</tag>
- The syntactic coloration in Data Feed Manager will also help you to avoid many errors in your pattern as in the example below.
- You can use one or more fallback variables in case of the previous is empty or null. If attributeA exists then the value will be attributeA, otherwise, the value will be attributeB, etc...
{{product.color | product.colour}}
- CDATA is recommended. CDATA stands for Character Data. It means that the data in between these tags include data that could be interpreted as XML markup, but should not be. (Wikipedia article)
<description><![CDATA[<p>Fantastic <b>Watch</b>, that not only tells you what time it is,but also gives the weather trends</p>]]></description>
10 Things to know when creating a CSV/TXT data feed with Data Feed Manager
Data Feed Manager allows you to generate CSV/TXT files in addition to XML files. This particular file format can be used for some shopping engines like Amazon, Shopzilla, Twenga, etc.
Data Feed Manager for Magento 2 provides you all you need to create any specific CSV/TXT file that you want.
Each shopping engine has its own requirements and column names. Some require fields enclosure, others need specific delimiters.
You may need to add a special header to your file (for Amazon data feeds for example).
- A CSV file consists of any number of records. Each record consists of fields that are separated by other characters or strings. There is one row per record (so, one per product). Below is an example of CSV file content:
- You need to define delimiters to separate your fields ( ';' ',' '|' ' ab' or '[|]' for example) and enclosures for your data (" or ').
- You can enter the attribute names in each Column name fields (check the shopping engine specifications to know which names are required). For example:
- You can include in each Pattern field one or several Magento 2 attributes. An attribute is specified by its attribute code and must be enclosed using double brackets and preceded by an object. For example, to return the product SKU, you should use:
{{product.sku}}
- You can also include some fixed values. Fixed values are simply text. For example, instead of {{product.manufacturer}} to retrieve the brand for each product, you could use directly:
YOUR BRAND
- You have also the possibility to add several attributes and fixed values in the same field. For example, instead of {{product.url}}, you could use:
{{product.url}}?_campaign=google&_adwords=test123
- You can use one or more fallback variables in case of the previous is empty or null. If attributeA exists then the value will be attributeA, otherwise, the value will be attributeB, etc...
{{product.color | product.colour}}
- You're allowed to use PHP code if you want to customize the pattern. You just have to write your PHP code in one single line, and it will work perfectly (check how to add PHP scripts into your patterns).
{{product.name output="wyomind_strtolower($self)"}}
- You can add a field by using the button Insert a new field. The fields order can be easily reordered by using the up and down arrows.
- You can Preview your data feed to avoid any error in your pattern.
How is a variable structured?
To modify your pattern as you want, before anything you need to respect a particular syntax. Indeed, in order to retrieve attributes, the Data Feed Manager extension uses a specific structure. Then it is essential that you know how the variable is built to be able to configure your data feed according to your needs.
The above screen details the different components of a variable.
- object
Defines what is the target for the attribute to retrieve. It can be a simple product, a parent, configurable, bundle, or grouped one. - attribute
Defines the code of the attribute to retrieve. For example, the price, the URL... - parameters
Defines some additional parameters for specific attributes such as the currency or the VAT rate. - value
Defines the different values available for the previous parameter.
Attribute specifications
The data feed pattern is totally customizable.
OBJECTS
In order to retrieve the value of an attribute, you need to define which object is targeted. Below are the different types of objects that you can use.
{{product.attribute_code}}
Retrieves the attribute for the product.
For example:
{{product.sku}}
{{product.color}}
{{parent.attribute_code}}
Retrieves the parent attribute value.
The parent value is retrieved only if the simple (item) product is associated with a parent product, if not, nothing is retrieved.
The parent product may be a configurable, a grouped, or a bundle product. The first parent product that matches the simple product is used to get the attribute value.
For example:
{{parent.product_type}}
{{parent.brand}}
{{configurable.attribute_code}}
Retrieves the first configurable parent attribute value.
The configurable product value is retrieved only if the simple product is associated with a configurable product, if not, nothing is retrieved.
For example:
{{configurable.image_link}}
{{configurable.url}}
{{grouped.attribute_code}}
Retrieves the first grouped parent attribute value.
The grouped product value is retrieved only if the simple product is associated with a grouped product, if not, nothing is retrieved.
For example:
{{grouped.google_product_category}}
{{grouped.url}}
{{bundle.attribute_code}}
Retrieves the first bundle parent attribute value.
The bundle product value is retrieved only if the simple product is associated with a bundle product, if not, nothing is retrieved.
For example:
{{bundle.sale_price}}
{{bundle.price}}
PRODUCT IDENTIFIERS
You'll find below the attributes the most commonly used to identify the products in data feeds patterns.
{{object.id}}
Retrieves the id of the product.
For example:
{{product.id}}
{{object.sku}}
Retrieves the sku of the product.
For example:
{{product.sku}}
{{object.brand}}
Retrieves the brand of the product.
For example:
{{product.brand}}
Attention, this attribute is an example and can differ according to the configuration of your Magento 2 store.{{object.manufacturer}}
Retrieves the brand of the product.
For example:
{{product.manufacturer}}
BASIC INFORMATION
You'll find below the attributes that are generally used to define basic information of products in the data feeds.
{{object.inc}}
Retrieves an auto-incremented value, starting at 1.
For example:
{{product.inc}}
{{object.name}}
Retrieves the name of the product.
For example:
{{product.name}}
{{object.description}}
Retrieves the description of the product.
For example:
{{product.description}}
{{object.short_description}}
Retrieves the short description of the product.
For example:
{{product.short_description}}
{{object.condition}}
Retrieves the condition of the product.
For example:
{{product.condition}}
{{object.weight}}
Retrieves the weight of the product.
For example:
{{product.weight}}
{{object.type_id}}
Retrieves the type of the product.
For example:
{{product.type_id}}
{{object.children}}
Retrieves the children of the product.
For example:
{{product.children}}
You also have the possibility to use some parameters with this attribute:
- separator = can be comma, pipe or semi-colon (by default: comma)
- identifier = can be SKU or id (by default: SKU)
For example:
{{product.children separator="pipe" identifier="id"}}
PRICES AND PROMOTIONS
Below is a list of the price attributes that you can use in your feed pattern. For most of them, you can add some parameters in order to define the currency used or the VAT to apply for example.
{{object.price}}
Retrieves the best price among all the prices defined.
If prices are exclusive of VAT and the product is liable to a unique VAT rate, the price retrieved will include this rate. Otherwise, the price exclusive of tax is retrieved.
For example:
{{product.price}}
You also have the possibility to use some parameters with this attribute:
- currency = automatically converts the original product price to a specified currency. It uses an exchange rate that you have already stored in your admin panel. By default, your local currency is used.
- vat_rate = is a floating value between 0.00 and 100.00 that represents an arbitrary VAT rate to apply. This parameter rewrites the VAT rule for the product except if the product doesn't have any tax class.
Here are some examples:
To convert the prices to EUR and apply a 20% VAT rate:
{{product.price currency=EUR vat_rate=20}}
To convert the prices to USD and not apply any VAT rate:
{{product.price currency=USD vat_rate=0}}
If the prices of your catalog are already including VAT:
{{product.price currency=USD}}
To use an ISO2 code corresponding to one of the countries for which you specified a VAT rate in your tax settings:
{{product.price currency=EUR vat_rate=FR}}
This code may also be completed by an area code:
{{product.price currency=USD vat_rate=US/NY}}
To deduce the VAT corresponding to a country/area:
{{product.price currency=GBP vat_rate=-GB}}
To retrieve prices including different price values for simple products associated to a configurable one:
{{parent.price currency=EUR vat_rate=20}}
{{object.normal_price}}
Retrieves the base price and ignores any other existing price value.
For example:
{{product.normal_price}}
{{object.base_price}}
Retrieves the base price as defined in the database in the price index table.
For example:
{{product.base_price}}
{{object.special_price}}
Retrieves the special price if exists. If this price doesn't exist the value is null.
For example:
{{product.special_price}}
{{object.price_rules}}
Retrieves the price including the catalog price rules if indicated, if not, nothing is retrieved.
If prices are exclusive of VAT and the product is liable to a unique VAT rate, the price retrieved will include this rate. Otherwise, the price exclusive of tax is retrieved.
For example:
{{product.price_rules}}
{{object.sale_price}}
Retrieves the best promotional between price rules and special prices).
For example:
{{product.sale_price}}
{{object.sale_price_effective_date}}
Retrieves the sale price effective date as 2011-03-01T13:00-0800/2011-03-11T15:30-0800. If no date is defined or if the dates defined don't match with the current date, the value is null.
For example:
{{product.sale_price_effective_date}}
{{object.has_special_price}}
Retrieves either 1 if a special price exists or 0 if not.
You also have the possibility to use some parameters with this attribute:
- yes = value to retrieve if a special price exists. By default 1.
- no = value to retrieve if no special price exists. By default 0.
For example:
{{product.has_special_price yes="Special price" no="No special price"}}
{{object.has_sale_price}}
Retrieves either 1 if a promotional price exists or 0 if not.
You also have the possibility to use some parameters with this attribute:
- yes = value to retrieve if a promotional price exists. By default 1.
- no = value to retrieve if no promotional price exists. By default 0.
For example:
{{product.has_sale_price yes="Sale price" no="No sale price"}}
{{object.tier_price}}
Retrieves the tier price if exists. If this price doesn't exist the value is null.
For example:
{{product.tier_price}}
You also have the possibility to use some parameters with this attribute:
- customer_group_id = id of the customer group for which the tier price is valid (Check inStoresOther SettingsCustomer Groups).
- index = index of the Tier Price you want to retrieve.
- vat_rate = is a floating value between 0.00 and 100.00 that represents an arbitrary VAT rate to apply. This parameter rewrites the VAT rule for the product except if the product doesn't have any tax class.
- currency = automatically converts the original product price to a specified currency. It uses an exchange rate that you have already stored in your admin panel. By default, your local currency is used.
For example:
{{product.tier_price customer_group_id="1" index="1" vat_rate="DE" currency="EUR"}}
{{object.tier_price_qty}}
Retrieves the quantity defined for the tier price if exists. Otherwise, the value is null.
For example:
{{product.tier_price_qty}}
You also have the possibility to use some parameters with this attribute:
- customer_group_id = id of the customer group for which the tier price is valid (Check inStoresOther SettingsCustomer Groups).
- index = index of the Tier Price you want to retrieve.
- vat_rate = is a floating value between 0.00 and 100.00 that represents an arbitrary VAT rate to apply. This parameter rewrites the VAT rule for the product except if the product doesn't have any tax class.
- currency = automatically converts the original product price to a specified currency. It uses an exchange rate that you have already stored in your admin panel. By default, your local currency is used.
For example:
{{product.tier_price_qty customer_group_id="2" index="1" vat_rate="FR" currency="EUR"}}
{{object.min_price}}
Retrieves the minimum price.
This attribute is used for configurable, bundle, or grouped products.
If prices are exclusive of VAT and the product is liable to a unique VAT rate, the price retrieved will include this rate. Otherwise, the price exclusive of tax is retrieved.
For example:
{{product.min_price}}
{{object.max_price}}
Retrieves the maximum price.
This attribute is used for configurable, bundle or grouped products.
If prices are exclusive of VAT and the product is liable to a unique VAT rate, the price retrieved will include this rate. Otherwise, the price exclusive of tax is retrieved.
For example:
{{product.max_price}}
{{object.promotion_id}}
Retrieves the product promotion id if it exists and if the Google Merchant Promotions extension is installed.
For example:
{{product.promotion_id}}
{{object.catalog_rule_id}}
Retrieves the first catalog price rule id applied to the product if it exists
For example:
{{product.catalog_rule_id}}
{{object.tax_class}}
Retrieves the product tax class if it exists.
For example:
{{product.tax_class}}
LINKS
Below are listed the attributes that are generally used to retrieve any kind of link.
{{product.url_config}}
Retrieves URL to pre-select the simple product attributes from its configurable.
You also have the possibility to use some parameters with this attribute:
- currency=XXX = This will add ?currency=XXX to the generated URL.
The access to the generated URL will switch the product page to the corresponding currency
For example:
{{product.url_config currency=USD}}
This will generate:
https://www.yourstore.com/chaz-kangeroo-hoodie.html?currency=USD#142=5594&93=5476
{{object.url}}
Retrieves the product’s canonical absolute URL.
You also have the possibility to use a parameter with this attribute:
- currency=XXX = This will add ?currency=XXX to the generated URL.
The access to the generated URL will switch the product page to the corresponding currency
For example:
{{product.url currency=EUR}}
This will generate:
https://www.yourstore.com/joust-duffle-bag.html?currency=EUR
{{object.image_link}}
Retrieves the product’s main image.
You also have the possibility to use some parameters with this attribute:
- index = index of any additional images to retrieve. It can be positive or negative.
By default 0 (the main image). - role = role of the image to retrieve. Also works with the roles configured by the admin.
For example:
To retrieve the second image, use:
{{product.image_link index=2}}
To retrieve the last image, use:
{{product.image_link index=-1}}
To retrieve the second to last image, use:
{{product.image_link index=-2}}
To retrieve the thumbnail image, use:
{{product.image_link role="thumbnail"}}
{{object.host}}
Retrieves the host URL, for example: https://www.website.com
Example with the small_image attribute:
{{product.host}}/media/catalog/{{product.small_image}}
{{object.uri}} or {{object.url_key}}
Retrieves the product canonical relative url.
For example:
https://www.mywebsite.com/mystore_code/{{product.uri}}
CATEGORIES
To retrieve the categories of your products, you can check the below attributes.
{{object.categories}}
Display the category paths in which the product may be found.
All category paths are listed under the categories attribute from the shortest to the longest path as in the below example:
- Default Category
- Default CategorySales
- Default CategoryClothes
- Default CategoryClothesMen
- Default CategoryClothesMenPants
- Default CategorySalesSpring and Summer Sales
In order to display a specific category path you have the possibility to use some parameters with this attribute:
- nth: display the nth category path, if not specified the 1st category is used by default. Negative values are allowed.
- from: display a category path starting from the nth category level, if not specified the 1st category level is used by default. Negative values are allowed.
- length: display a category path limited to the given number of category levels, if not specified the whole path is displayed by default.
- separator: the character used to separate each category level.
- url: replace the categories names by their URLs
{{product.categories nth="1"}}
Shows the first category Default Category
{{product.categories nth="-1"}}
Shows the last category path: Default CategorySalesSpring and Summer Sales
{{product.categories nth="3" separator="-"}}
Shows the 3th category path and change the category levels separator to "-": DEFAULT CATEGORY - CLOTHES
{{product.categories nth="-2"}}
Shows the before last category path: Default CategorYClothesMenPants
{{product.categories nth="-2" from="2"}}
Shows the before last category path from the 2nd category level: ClothesMenPants
{{product.categories nth="-1" from="-1"}}
Shows the last category path from the last category level: Spring and Summer Sales
{{product.categories nth="-2" from="2" length="1"}}
Shows the before last category path from the 2nd category level with only one category level: Clothes
<?php /* {{product.categories_url}} */ ?> {{product.categories url=1 nth="-2" from="2"}}
Shows the before last category path from the 2nd category level by replacing the names of the categories by their URLs:
https://www.yourstore.com/clothes.html > https://www.yourstore.com/clothes/men.html > https://www.yourstore.com/clothes/men/pants.html
{{object.category_mapping}}
Retrieves any new category that you have assigned (in the Categories tab) to the item’s own product category. If no mapping is assigned to the first category found, the second category will be used etc…
You also have the possibility to use some parameters with this attribute:
- index = index of the category mapping
For example:
{{product.category_mapping index=0}}{{product.category_mapping index=1}}{{product.category_mapping index=2}}{{product.category_mapping index=3}}{{product.category_mapping index=4}}
Will retrieve a maximum of 5 category mappings in 5 separate tags.
{{object.google_product_category}}
Retrieves the Google category that you have assigned (in the Categories section) to the first category found for the product (index 0).
For example:
{{product.google_product_category}}
To find the Google categories that match with your categories: https://support.google.com/merchants/answer/160081?hl=en{{object.attribute_set}}
Retrieves the attribute set of the product.
For example:
{{product.attribute_set}}
AVAILABILITY AND INVENTORY
{{object.status}}
Retrieves either 1 if the product is enabled or 2 if the product is disabled.
For example:
{{product.status}}
{{object.qty}}
Retrieves the available quantity.
The quantity retrieved for configurable products is based on the sum of simple products.
You also have the possibility to use some parameters with this attribute:
- float = is the number of decimals.
- stock_id = id of the stock for which you want to retrieve the quantity.
The sum of the quantities of the sources associated with the stock is retrieved (Magento Multi Stock Inventory module).By default, the value of the default stock is retrieved.
- source_code = code of the source for which you want to retrieve the available quantity.
By default, the value of the default source is retrieved.
For example:
{{product.qty float=1 stock_id="1"}}
{{product.qty float=2 source_code="store_1"}}
{{object.availability}}
Retrieves either "in stock" if the product is in stock, "out of stock" if the product is out of stock, or "available for order" if the product is backordered.
You also have the possibility to use some parameters with this attribute:
- in_stock = value to retrieve if the product is in stock.
- out_of_stock = value to retrieve if the product is out of stock.
- backorderable = value to retrieve if the product is backorderable.
- stock_id = id of the stock for which you want to retrieve the availability (Magento Multi Stock Inventory module).
By default, the value of the default stock is retrieved. - source_code = code of the source for which you want to retrieve the availability.
By default, the value of the default source is retrieved.
For example:
{{product.availability stock_id="2" in_stock="Currently in stock" out_of_stock="Out of stock" backorderable="Available for order"}}
{{product.availability source_code="store_1" in_stock="In Stock" out_of_stock="No more Stock" backorderable="Can be ordered"}}
{{object.is_in_stock}}
Retrieves the stock status "in stock" or "out of stock".
You also have the possibility to use a parameter with this attribute:
- stock_id = id of the stock for which you want to retrieve the status (Magento Multi Stock Inventory module).
By default, the value of the default stock is retrieved. - source_code = code of the source for which you want to retrieve the status.
By default, the value of the default source is retrieved.
For example:
{{product.is_in_stock stock_id="1"}}
{{product.is_in_stock source_code="store_1"}}
REVIEWS
You can also retrieve information on your products reviews using the following attributes.
{{object.review_count}}
Retrieves the number of reviews for the product.
You also have the possibility to use some parameters with this attribute:
- store_id = id of the store view
For example:
{{product.review_count store_id=1}}
{{object.review_average}}
Retrieves the average score of all the product's reviews.
You also have the possibility to use some parameters with this attribute:
- store_id = id of the store view
- score_base = base ratings
For example:
{{product.review_average store_id=1 score_base=5}}
PRODUCT VARIANTS
In the case where you're using product variations (color, size, or gender) then you can use the following attributes. Attention, these attributes are examples and can differ according to the configuration of your Magento 2 store.
{{object.relation_ship}}
Retrieves all the attribute names for which the configurable product has simple ones defined.
For example:
{{product.relation_ship}}
{{object.gender}}
Retrieves the gender of the product.
For example:
{{product.gender}}
{{object.age_group}}
Retrieves the age group of the product.
For example:
{{product.age_group}}
{{object.color}}
Retrieves the color of the product.
For example:
{{product.color}}
{{object.size}}
Retrieves the size of the product.
For example:
{{product.size}}
{{object.material}}
Retrieves the material of the product.
For example:
{{product.material}}
{{object.pattern}}
Retrieves the pattern of the product.
For example:
{{product.pattern}}
GENERAL PARAMETERS
Below are listed all the parameters that you can use with any attribute in your data feeds.
{{object.attribute prefix="value"}}
The prefix is what will be displayed before the attribute value only if it is not null, otherwise, nothing is retrieved.
Below are some examples:
To add the currency symbol before the price and not retrieve anything when the value of the attribute is null:
{{product.price currency=USD vat_rate=0 prefix="$"}}
To add the weight unit before the attribute value and not retrieve anything when that value is null:
{{product.weight prefix="LBS "}}
{{object.attribute suffix="value"}}
The suffix is what will be displayed after the attribute value only if it is not null, otherwise, nothing is retrieved.
Below are some examples:
To add the currency code after the price and not retrieve anything when the value of the attribute is null:
{{product.price currency=USD vat_rate=0 suffix=" USD"}}
To add the weight unit after the attribute value and not retrieve anything when that value is null:
{{product.weight suffix=" LBS"}}
{{object.attribute as="myVariable"}}
The as parameter allows you to store the value of a given attribute into a variable for a later use in one of your PHP script or in a condition (see if parameter).
Notice, the attribute call even if it uses the as parameter will produce an output in the data feed expect if you add the output attribute with the value null (see output parameter)
Here are a few examples:
Display the product name and store the value in a variable $name:
<!-- Product name is displayed and stored under a new variable "name" --><name>{{product.name as="name"}}</name>
$name can be then used in a PHP script latter in the template
<?php /* If variable $name is equal to "Apple", then display "Apple" then display "Banana"*/if($name=="Apple") return $name;else return "Banana";?>
Store the visibility of a product and use it in a condition for another attribute
<!-- Product visibility is stored under a new variable "visibility" and the attribute doesn't display -->{{product.visibility as="visibility" output="null"}}<!-- If the product is not visible individually (1) then we display the parent product url, otherwise we use the product url--><url>{{parent.url if="visibility==1" | product.url}}</url>
{{object.attribute if="condition"}}
The if parameter allows you to define one or more necessary conditions to display the given attribute in the data feed.
One condition is built with 3 items :
- the variable to check :
a product attribute
a variable previously stores thanks to the as parameter (see as parameter) - the comparison statement
== equal
<= lower or equal to
=> hieght or equal to
< lower than
> higher than
!= different from - the value
Example:
<!-- Product description will be displayed only if product brand is equal to "Apple" --><name>{{product.description if="product.brand==Apple"}}</name>
<!-- Product weight will be displayed only if the product is not virtual AND not downloadable--><weight>{{product.weight if="product.type_id!=virtual" if="product.type_id!=downlodable"}}</weight>
{{object.attribute output="functions"}}
You can use the basic functions (see basic functions), the advanced functions (see advanced functions) or any php functions.
You must refer to the attribute by using the $self variable as the function's parameter.
Example :
<!-- Get the product name with the first letter of each word in uppercase --><name>{{product.name output="ucwords($self)"}}</name>
If you want to use several functions, those must be imbricated as you do for with PHP:
Example :
<!-- Remove all html tags from the description and limit the description to the first 100 characters --><name>{{product.description output="substr(strip_tags($self),100"}}</name>
You can also use null to display an empty string or you can use any string to display a specific message:
Example :
<!-- If product price is lower than $10 then display "Free Shipping"--><shipping_cost>{{product.price if="product.price<10" output="'Free Shipping'"}}</shipping_cost>
The output parameter allows you to define the output format for a given attribute.{{object.attribute php="functions"}}
The php parameter acts exactly as the output parameter.
BASIC FUNCTIONS
You can use any of the native php functions as well as all of the following ones with the default attributes that are defined in your Magento 2 back-office and also any attribute you have defined for your products (eg: name, description, short_description, weight, size, color…) apart from those which generate XML.
The syntax to use in order to include php functions in the variables is:
{{object.attribute output="function(parameters)"}}
You can also apply one or more functions to all of these attributes by using the following syntax:
{{object.attribute output="function1(function2(function3($self,parameters)))"}}
All options are executed in the written order:
<title>{{product.name}}</title><title>{{product.name output="wyomind_strtoupper($self)"}}</title><title>{{product.name output="wyomind_strtoupper(wyomind_substr($self,20,'...'))"}}</title>
This will produce:
<title>Affirm Water Bottle</title><title>AFFIRM WATER BOTTLE</title><title>AFFIRM WATER...</title>
float($self,$decimal)
Converts a numeric value to a floating number.
You need to define some parameters:
- decimal = number of floating number. By default: 0
For example:
<g:shipping_weight> {{product.weight output="float($self,2)"}}kg </g:shipping_weight>
cleaner($self)
Removes all characters that don't belong to the UTF-8 charset.
For example:
<g:title> {{product.name output="cleaner($self)"}} </g:title>
inline($self)
Removes all EOL characters from the value.
For example:
<description> {{product.description output="inline($self)"}} </description>
IMPROVED FUNCTIONS
The improved functions are used in the same way as the basic php functions but offer more possibilities. They are a rewrite of the native php functions but have been improved for a specific use of the Data Feed Manager extension.
wyomind_strtoupper($self)
Transforms the value to uppercase.
For example:
<g:title>{{product.name output="wyomind_strtoupper($self)"}}</g:title>
wyomind_strtolower($self)
Transforms the value to lowercase.
For example:
<tag>{{product.name output="wyomind_strtolower($self)"}}</tag>
wyomind_implode($separator,$self)
Joins all array elements in a string.
You need to define some parameters:
- separator = string used between each value. By default: ,
This function may be useful for multi-select attributes like climate, activity general...
For example:
<activity> {{product.activity_general output="wyomind_implode('-',$self)"}} </activity>
Will give:
Outdoor-Running-Warmup-Lounge-Gym
wyomind_html_entity_decode($self)
Converts all HTML entities to their applicable characters.
For example:
<description> {{product.description output="wyomind_html_entity_decode($self)"}} </description>
wyomind_strip_tags($self)
Removes all HTML tags.
For example:
<description> {{product.description output="wyomind_strip_tags($self)"}} </description>
wyomind_htmlentities($self)
Converts all applicable characters to HTML entities.
For example:
<description> {{product.description output="wyomind_htmlentities($self)"}} </description>
wyomind_substr($self,$length,$end)
Truncates the value.
You need to define some parameters:
- length = maximum length of the value
- end = string that will be added at the end of the string. By default: ...
For example:
<description> {{product.description output="wyomind_substr($self,50,'...')"}} </description>
If there are HTML tags in your descriptions, you may need to use in combination with this function:
<description> {{product.description output="wyomind_strip_tags(wyomind_substr($self,50,'...'))"}} </description>
API PHP for Data Feed Manager
With Data Feed Manager you can use PHP scripts in different ways to fully customize and control the data feed output.
- Inline PHP scripts
Scripts that are added directly to the data feed template surrounded by PHP tags (<?php ... ?>)
- Custom attributes
Scripts that can be called by using the custom attribute name just like you do for any attribute in your data feed template. - Custom functions
Functions that can be called by using the function name and additional parameters and that can be applied to any attribute in your data feed template.
API coding standards
The Data Feed Manager PHP API uses the exact same syntax and standards as any PHP coding.
Attribute calls
For performance reasons, Data Feed Manager only loads in the collection of products the attributes that are explicitly required in the data feed template.
This means that only the attributes that are called using the template placeholders, {{scope.attribute_code}}, will be added to the collection of products.
As a consequence, when you try to access the value of an attribute from the $product object, you must be sure that the attribute has been added to the collection.
Most of the time when the returned value is null for a given attribute, it means the attribute is not loaded in the collection of products.
The best way to be sure that all the attributes you need are well loaded in the collection, is to add at the beginning of your template a simple script that lists all the attributes required.
<?php /* list of required attributes * {{product.attribute_1}} {{product.attribute_2}} {{product.attribute_3}} {{product.attribute_4}}...*/?>
Then you should be able to get the values of these attributes in your PHP script:
<?php return $product->getAttribute1();?><?php return $product->getAttribute2();?><?php return $product->getAttribute3();?>....
PHP functions in attribute calls
You can use any PHP function to apply in the attribute calls even if the function requires one or more additional arguments, for instance:
{{product.name output="str_replace('Apple','Banana',$self)"}}
You can use several consecutive functions:
{{product.ean output="str_pad(str_replace('X','0',$self),10,'0',STR_PAD_LEFT)"}}
Conditional values
To output values based on different conditions, use PHP conditional statements:
- if/else
<?php/* attribute {{product.sku}} required */if ($product->getSku()=="abc"){return "Alphabetic";}elseif($product->getSku()=="123"){return "Numeric";}else{return "Mixed";}?>
- switch/case
<?php/* attribute {{product.sku}} required */switch($product->getSku()){case "abc":return "Alphabetic";break;case "123":return "Numeric";break;default:return "Mixed";}?>
Opening and closing tags
When using the PHP API inline directly in your data feed template, you must use the opening and closing PHP tags (<? php ... ?>)
<?php if($product->getData('size')=="X-Large") {return "XL";}?>
Outputting a value
Return
Any value that you want to output in your data feed, must be returned with the return instruction.
<?php return "Don't miss! ".$product->getTitle();?>/* This script adds for each product in data feed a new output line * Don't miss! Iphone 5* Don't miss! Galaxy note 7* ... */
Variables scope
All variables available in PHP scripts have a local scope, this means they can't be shared between several scripts.
If you wish to share a variable with different scripts all along the data feed generation process, then the variable must be set as a global variable.
<?php global $increment;$increment++;return $increment;/* This script will output a incremental $variable* 1* 2* 3* ...*/?>
API Objects, Variables and Methods
Object $product
$product is an instance of Mage_Catalog_Model_Product. It contains all methods available by default and some other specific to Data Feed Manager.
The list below includes the main methods available to use:
- $product->getCategoriesArray()
Retrieves an array of arrays that describes the categories to which belongs the products - $product->getCategoryIds()
Lists all category ids in which the product may be found - $product->getVisibility()
Returns the visibility of the product (1 = not visible individually, 2 = catalog, 3 = search, 4 = catalog and search) - $product->getStatus()
Returns the status of the product (1 = enabled, 2 = disabled) - $product->getData($attributeCode)
Returns the value of the given attribute code - $product->getAttributeText($attributeCode)
Returns the textual value of the given attribute code
Object $this
$this is an instance of Wyomind_datafeedmanager_Model_Feed.
It provides a few useful methods:
- $this->hasParent($product, $type="parent")
Returns a Boolean value whether a product has a parent from the give type (parent, configurable, grouped, bundle) or not
- $this->getParent($product, $type="parent", $strict=false)
Returns a product object of the given parent type (parent, configurable, grouped, bundle) if available or the product object passed as 1st parameter when $strict parameter is set on false. - $this->skip()
Skips the current product, useful to filter out some products based on specific condition
String | Integer | Boolean | Array in variable $self
$self is the value of the attribute for the current product.
This variable is only available for custom attributes and functions.Custom variables use
Data Feed Manager allows you to create your own variables and to add them to your data feed.
Create a custom variable
To create custom variables from your Magento admin, go to :
products Data Feed Manager Custom variables
Some templates of use are loaded by default when installing the extension.
Here is how to proceed:
An example of custom variables
Replace some words in the product description:
<?php
$search=array('Nokia','BlackBerry','apple');
$replace=array("NOKIA","BLACKBERRY","APPLE");
return str_ireplace($search,$replace,$product->getDescription());
?>
Create a thumbnail of the product image:
<?php
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$_imagehelper = $objectManager->get('MagentoCatalogHelperImage');
return $_imagehelper->init($product, 'image',['type'=>'image'])->resize(200,200)->getUrl();
?>
Filter out the product that matches a condition:
<?php
if(strlen($product->getUpc())>=12)
return $product->getUpc();
elseif ($product->getMpn())
return $product->getMpn();
else
$this->skip();
?>
Calculate the sum of all quantity available for the configurable product:
<?php
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$childProducts = $product$product->getTypeInstance()->getUsedProducts($product);
$stock_count=0;foreach($childProducts as $child) {
$stockItem=$objectManager->get('MagentoCatalogInventoryModelStockItem');
$stock_count+=(int)$stockItem->loadByProduct($child)->getQty();
}
return "<g:quantity>".$stock_count."</g:quantity>";
?>
Custom functions use
Data Feed Manager also allows you to create custom functions.
Create a custom function
To create your own functions, go to:
products Data Feed Manager Custom functions
Here is how to proceed:
Examples of custom functions
Pad an attribute to a certain length with another string:
<?php/** {{product.ean output="str_pad_custom($self,10,0)"}} * when ean is 12345, then the output is 0000012345 */return str_pad($self,$pad_length,$pad_string,STR_PAD_LEFT);/** could also be used as a inline function* {{product.ean output="str_pad($self,10,0,STR_PAD_LEFT)"}}*/?>
Format a number:
<?php /** {{product.price output="number_format_customl($self,2,',')"}} *when price is 9.99345, then the output is 9,99 */return number_format($self,$decimal,$decimal_separator,' ');/** could also be used as a inline function *{{product.ean output="number_format($self,2,',',' ')"}}*/?>