Here you will learn how to use tags to properly configure the template that will be later generated by the Magento 2 Data Feed Generator Extension. You will also find the full list of tags that can be in a template.
The Order of Using Tags
As you can see, a template consists of three separate sections: the header, the body, and the footer. The header and footer are repeated only once, so only document tags can be used here. Otherwise, the system will automatically delete any other tags (like catalog tags or product tags) in the file that will be displayed to the user. The body of the template is repeatable and is generated every time for each catalog or product depending on the type of feed (products or categories). For instance, if there are one hundred categories in the feed, the system will generate one hundred blocks of texts that will appear between the header and the footer, and data for changing tags will be generated for each category separately. For example, if there is a tag {category.name}, there will be a separate category name in each of the one hundred blocks of texts.
To create a template, use tags written in the following format:
{entity.property[|modifierName:modifierParam]}
For instance: {product.name}, {product.description|truncate:500}
You can use document tags in the body irrespective of the type of the feed. You can also use tags of categories if the type of the feed is ‘category’, tags of products if the type of the feed is ‘product’. When using the type of the feed “Product’, the system will automatically use the category data this product belongs to for processing category tags.
Example (the type of the feed ‘Product’):
<item>
<title>{product.name}</title>
<description>{product.description}</description>
<pubDate>{product.updated_at}</pubDate>
<link>{product.url}</link>
</item>
The Extension will generate several blocks according to the number of products available. The result will be as follows:
<item>
<title>BlackBerry 8100 Pearl</title>
<description>Like the BlackBerry 7105t, the BlackBerry 8100 Pearl is The BlackBerry 8100 Pearl sports
a large 240 x 260 screen that supports over 65,000 colors-- plenty of real estate to view your e-mails,
Web browser content, messaging sessions, and attachments.</description>
<pubDate>2013-04-30 12:56:37</pubDate>
<link>http://www.private-sales-v20.plumrocket.net/all/electronics/blackberry-8100-pearl.html</link>
</item>
The List of Tags
Document Tags
There is a list of all document tags in the table below.
Tag | Description |
---|---|
{site.now} | Current time in the format “Y-m-d H:i:s” |
{site.name} | The name of the store according to global settings |
{site.phone} | Store contact phone number |
{site.address} | Store address |
{site.url} | URL store address |
{site.currency_code} | Store currency code, e.g. USD |
{count} | The number of positions in the feed. It can only be used in Footer Template |
Formatting Tags:
Tag | Description |
---|---|
{no_br} … {/no_br} | Removes the hyphens replacing them with space gaps in order to prevent words overlapping |
{no_html} … {/no_html} | Removes all tags (Note! It does not produce tag codes but totally removes a tag) |
{no_quotes} … {/no_quotes} | Removes quotation marks |
These tags can be randomly and partially overlapped. Below are the examples of usage:
{no_br}{ho_html}{product.description}{/no_html}{/no_br}
{ho_html}{no_br}{product.description}{/no_html}{/no_br}
Category Tags (Catalog Tags)
There is a list of all category tags in the table below. The tag writing is carried out in the following way: {category.XXX}, where XXX is one of the tags like {category.meta_description} will show the meta description of the current category.
Tag | Description |
---|---|
children_count | The number of subcategories in a category |
created_at | The time and date of category creation |
description | Category description |
entity_id | Category ID |
image | File name of image, example “shirt.jpg” |
image_url | Full url of image, example “http://www.example.com/media/category/image/p/12/s/shirt.jpg” (Recommend) |
meta_title | Category meta title |
meta_keywords | Category meta keywords |
meta_description | Category meta description |
name | Category title |
parent_id | Parent category ID |
privatesale_date_start | The date and time of sales beginning (Private Sales Extension Required) |
privatesale_date_end | The date and time of sales ending (Private Sales Extension Required) |
thumbnail | Thumbnail file name, example “shirt.jpg” |
thumbnail_url | Full url of thumbnail, example “http://www.example.com/media/category/cache/128×24/h/shirt.jpg” |
updated_at | The date and time of the latest category update |
url | Absolute category path |
open_url | Absolute category path for guests (Url Manager Extension Required) |
url_key | Category name in URL |
url_path | Relative Category path |
brand_name | Brand name (Shop by Brand Extension Required) |
brand_comment | Comment to the brand (Shop by Brand Extension Required) |
brand_link | Brand link (Shop by Brand Extension Required) |
brand_image | Brand image (Shop by Brand Extension Required) |
Products Tags
There is a list of all product tags in the table below. The tag writing is carried out in the following way: {product.XXX}, where XXX is an arbitrary tag like {product.name} – the name of the product.
Tag | Description |
---|---|
breadcrumb | The deepest breadcrumb of the product |
created_at | The Date and time of product creation |
description | Product Description |
entity_id | Product ID |
final_price | The final product price |
image | Product image relative path |
image_url | Product image absolute path |
meta_description | Product meta description |
meta_keyword | Product meta keyword |
meta_title | Product meta title |
name | Product title |
news_from_date | The date marking the “New Product” status |
news_to_date | The final date of the “New Product” status |
price | The price of a product |
price_with_currency | Product price in the currency |
price_with_tax | Product price including tax |
price_without_tax | Product price excluding tax |
short_description | Short description of a product |
sku | Stock-keeping unit of a product |
small_image | Product image relative path to cart page |
small_image_url | Product image absolute path to cart page |
sold | The quantity of sold products |
special_from_date | The date marking the beginning of the special price of the product |
special_to_date | The date marking the end of the special price of the product |
special_price | Special Price. If the field is empty regular price will be displayed |
thumbnail | Product image relative path to the list of products |
thumbnail_url | Product image absolute path to the list of products |
qty | The number of products available in stock |
updated_at | The date and time of the latest product update |
url | Absolute product path |
url_key | Product name in URL |
url_path | Relative product path |
weight | Product weight |
Extended Tags:
Tag | Description |
---|---|
{product.child_items} … {/product.child_items} | Block with child items |
{product.child} … {/product.child} | The block with child items is added to {product.child_items}, and does not work beyond it. Its content will be repeated for each child item of the parent one, when tags parsing is launched. |
{product.parent.sku} | Parent product SKU, works only for child products of a configurable product. You can also use some other attributes instead of SKU, for example: {product.parent.name} |
Child Tags
Child tags coincide with those used for Product Tags (see described above), except for .child_items and .child. The tags {child.xxx} are available and processed only if they belong to the block {product.child} … {/product.child}. Otherwise, these will be removed from the result.
Below are the examples of tags usage.
{product.child_items}
<variants>
{product.child}
<variant>
<sku>{child.sku}</sku>
<color>{child.color}</color>
<size>{child.size}</size>
<detail_url>{product.url}</detail_url>
</variant>
{/product.child}
</variants>
{/product.child_items}
As a result, if you use the code described above, the XML structure will look like this:
<variants>
<variant>
<sku>ZOO0241-LB</sku>
<color>BLACK</color>
<size>L</size>
<detail_url>http://www.shopeer.com/product.html?id=10802</detail_url>
</variant>
<variant>
<sku>ZOO0241-MN</sku>
<color>NAVY</color>
<size>M</size>
<detail_url>http://www.shopeer.com/product.html?id=10935</detail_url>
</variant>
<variant>
<sku>ZOO0241-SR</sku>
<color>RED</color>
<size>S</size>
<detail_url>http://www.shopeer.com/product.html?id=12618</detail_url>
</variant>
</variants>
The List of Modifiers
Modifiers change values before pasting them into text. You can add one or more modifiers to each tag:
date_format
Formats the date value to the specified format. It can only be used for values that contain a date or timestamp.
Format: date_format:{PHP date format}
Example: {site.now|date_format:Y-m-d/H:i:s}
truncate
Truncates the string if it is longer than the specified length. Also adds an ellipsis at the end by default. Ellipsis are taken into account in a given length.
Format: truncate:{length}:[{string for end}]
Example: {product.description|truncate:500}
size
Allows you to resize the image. Works only for product.image_url, product.thumbnail_url, product.small_image_url.
Format: size:{width}:[{height}]
Example: {product.image_url|size:500:400}
replace
Replaces a character or string with the specified string (you can specify an empty string). Works for all data except an array.
Format: replace:{search}:{replace}
Example of deleting a character: {product.meta_keyword|replace:,:}
Example of symbol replacement: {category.breadcrumb_path|replace: > : /}
suffix
Adds a suffix to a field value only when the value is set. You can use it for strings that require clarifying the value, e.g. adds ‘kg’ in the following string: <weight>1 kg</weight>
. The {product.weight|suffix:’ kg’} tag allows hiding ‘kg’ when the field is empty.
Format: suffix:{suffix}
Example: {product.weight|suffix: kg}
Example with space: {product.weight|suffix:' kg'}
separator
Joins array elements with a string
Format: separator:{string}
Example: {product.breadcrumb|separator:,}
Example with space: {product.breadcrumb|separator:' / '}
limit
Sets limits for values. Works only with arrays.
Format: limit:{length}
Example: {product.categories|limit:30}
repeat
Sets the entity to be repeated several times. Works only for paired tags and nested arrays.
Format: repeat:{child_entity_name}
Example: {product.media_gallery|repeat:gallery_image}
Example of the use:
{product.media_gallery|repeat:gallery_image|limit:10}
{gallery_image.url}
{/product.media_gallery}