Recently, the Google Product Feed for one of my clients simply stopped working (sporadically)

Investigation revealed timeout issues happening during the feed file generation, even though the feed was allowed to run for hours, via settings and code. The problem seemed to occur more often than not, making for poor service on updating their Google Merchant Centre products.

Dynamic Category Products to the rescue!

First, how the feed was created, and why it was not working 

The client uses a very nice extension from Xtento, aptly named 'Product Feed'
I want to note that the timeout issue has no reflection on their extension, which seems well coded, and does a great job. It has the ability to define multile feeds, export destinations, and, best of all: use XSLT to define the feed output. Works great.

The issue is the growing catalog of active products, and the need from the client to limit products, based on a Start and End dates, which are custom date attributes. A lot of products would not be set 'out of stock', or disabled, as the date ranges determined if the product would appear in the frontend catalog. (I do not know why the built in active from/to date ranges were used, as I did not build the initial store. I now simply extend and maintain the store)

The Xtento extension has many ways to filter products, which then gets processed by the XSLT processor. It cannot, however, limit by the date ranges, as that would require constant update of the feed profile filters, having set the correct date ranges of from/to

Not ideal at all.

To solve this,  date variables were used in the XSLT, to filter the products during processing.

This involved using XSL variable for dates, based of the current days date.

<xsl:variable name="todayDate" select="php:functionString('strftime', '%Y-%m-%d')"/>
<xsl:variable name="todayDateUNIX" select="php:functionString('strtotime',$todayDate)"/>
<xsl:variable name="todayDateMinusOne"
select="php:functionString('strftime', '%Y-%m-%d',php:functionString('strtotime', concat($todayDate,' -1 day')))"/>
<xsl:variable name="todayDatePlusOne"
select="php:functionString('strftime', '%Y-%m-%d',php:functionString('strtotime', concat($todayDate,' +1 day')))"/>
<xsl:variable name="todayDateMinusOneUNIX" select="php:functionString('strtotime',$todayDateMinusOne)"/>
<xsl:variable name="todayDatePlusOneUNIX" select="php:functionString('strtotime',$todayDatePlusOne)"/>

and within the product foreach loop:

<xsl:variable name="startDate" select="start_date"/>
<xsl:variable name="endDate" select="end_date"/>
<xsl:variable name="startDateUNIX" select="php:functionString('strtotime',$startDate)"/>
<xsl:variable name="endDateUNIX" select="php:functionString('strtotime',$endDate)"/>

and then used in a conditional to limit the products that has valid date ranges.

<xsl:if test="$startDateUNIX &lt; $todayDatePlusOneUNIX and $endDateUNIX &gt; $todayDateMinusOneUNIX">

The problem with this setup was that all (most of) the store products would be fetched by the feed profile, and then processed in the XSLT. It would seem that, sometimes, the fetch of products would never complete/fail, and the XSLT would never even be reached.

The Solution:

Filter the products, first, by valid date range, which would limit the number of prodcts fetched by the feed, and of course be less products to process in the XSLT.

The obvious choise was to use my own Dynamic Catgeory Products extension, which already has the ability to filter products, based on the validity of date ranges, on the current day.

An example of such a rule would be:

Dynamic Date Range Rule

Before I go on, let me first explain how this works, as I get frequent quries from clients, not understanding the rule.

Date Ranges are attributes that have FROM and TO pairs. They are separate DATE attributes. The Dynamic Catgeory Products extension detects these pairs, and combines them as one DATE RANGE option. They are still available as singular attributes, for normal usage.

The 'is within range on day of viewing'  determines if the FROM / TO dates are BEFORE or AFTER the current date. So, IN RANGE of today. Put another way: If TODAY is IN BETWEEN the FROM / TO dates, or EQUAL to either, then rule validates true.

Ok, back to the article topic.

Using the Dynamic Date Range rule, it is possible to populate products into a category, and never need to manually update any dates. The products will drop off as their dates fall outside the range, and appear, as their dates come in range.

Add some more filters

 Full Dynamic FIlters


and you end up with a category containing all the products that shoudl be in the Google Product Feed.

Awesome :)

Back to the Xtento feed configuration, and it is now a simple matter of defining a filter that only includes the products on that category:

Xtento Feed FIlter

The end result is a working feed, which also processes a lot faster than the old one. The XSLT was also simplified, as the calcualted dates were no longer needed

Everyone is happy :)


Using Dynamic Categories, it is very possible to create multiple hidden categories, which contain subset of products, ready to be processed for external feeds, or for anything else, not just feeds.

As one of ProxiBlue's clients had once noted: 

I use this extension in combination with M2e pro's automatic listing actions for categories - and it's completely changed our whole eBay management workflow... I could not be happier!