Paid feature

This is a paid feature, please check out the Datafeeds App in the store to access this solution. 

Impact on the sending speed

This Smarty solution can impact the sending speed of your email if a personalized feed is used within a batch selection or when the feed is too large in terms of data. An alternative is to preload the data into the data model beforehand and use it to display the information in the email.


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.

getRss

{{getRss assign='<Name>' link='<URL>'}}

Good to know

The getRSS smarty method doesn't support enclosed arguments within an XML element such as the example argument "name" below:

<element name="Test">

Arguments

The following arguments can be used with this function:

ArgumentDescription
assign

The variable name in which the result of the feed should be made available.

linkThe URL to the RSS or XML source
limitThe 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:

  • `true`: Cancel the rest of the delivery on RSS error.
  • `false`: Ignore the error message on RSS error and return the variable empty.

Examples

Below is an example in combination with a product feed fetched using the DataFeeds app, utilizing the provided XML:

XML productenfeed
<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.

cancel_mail with getRSS

{{* Fetch XML feed *}}
{{getRss assign='productsXML' link='https://cdn.msdp1.com/public/tpm/xml/productfeed.xml'}}

{{* Loop door de producten *}}
{{$available_products = 0 }}
{{foreach from=$productsXML.channel.0.item item=product}}
  {{if $product.availability|lower eq 'sold out'}}
   {{$product.title}} is sold out.  
  {{else}}
   {{counter assign="available_products"}}
   {{$product.title}} now available!
  {{/if}}
{{foreachelse}}
   {{* In case no products are present, cancel the delivery for all customers in the selection *}}
   {{cancel_mail for="allcustomers"}}
{{/foreach}}

{{* If no sellable products are present, cancel the delivery for all customers in the selection *}}
{{if empty($available_products)}}
   {{cancel_mail for="allcustomers"}}
{{/if}}