Using the getRss function, an external XML/RSS feed can be fetched when rendering the email. This can be used to display information such as branches, personalized product recommendations, or general product details within the email.
Arguments
The following arguments can be used with this function:
Argument | Description |
---|---|
assign | The variable name in which the result of the feed should be made available. |
link | The URL to the RSS or XML source |
limit | The maximum number of elements to be retrieved at the first level of the feed. |
cancelonfail | If an error occurs while loading the RSS feed, this argument can be used to indicate whether the delivery should be canceled for all remaining customers in the selection or if the delivery should proceed with an empty variable. By default, the delivery will be canceled for all remaining customers. The following values can be used:
|
Examples
Below is an example in combination with a product feed fetched using the DataFeeds app, utilizing the provided XML:
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<channel>
<item>
<id>1</id>
<title>Home loungeset Cardona</title>
<category>Tuinset</category>
<url>https://example.org/first-item</url>
<image>https://example.org/first-item.png</image>
<price>599.00</price>
<availability>In Stock</availability>
</item>
<item>
<id>2</id>
<title>Home loungeset Örebro</title>
<category>Tuinset</category>
<url>https://example.org/second-item</url>
<image>https://example.org/second-item.png</image>
<price>279.00</price>
<availability>In Stock</availability>
</item>
<item>
<id>3</id>
<title>Home loungeset Claire</title>
<category>Tuinset</category>
<url>https://example.org/third-item</url>
<image>https://example.org/third-item.png</image>
<price>479.00</price>
<availability>Sold out</availability>
</item>
</channel>
</rss>
In this scenario, a check is performed to determine if there are products present in the feed and whether there is a sellable product among them. If these conditions are not met, the email delivery is canceled for the entire selection. In this example, besides using the cancel_mail function, the following Smarty methods are also utilized: foreach, if, empty, lower, and counter.