CartProductFeed API: Feed Generation Part 3 – PActionBeforeFeed
Data leaves the Content Management System and enters a feed in a controlled process. There are four points where your custom modifier can hook the feed generation process. This post discusses the third of those four points and the differences.
PActionBeforeFeed is the third hook. It takes the harmonized product and makes any changes that need to occur before the feed-provider steps in to take over. (A harmonized product is what you see in ProductList XML. All CMS databases will generate similar harmonized products – CartProductFeed will automatically convert the terms for you).
The Action-before-feed is one of the more complex phases because at this point description_long and description_short become one attribute “description” and price gains formatting if it doesn’t already have one.
A simple example:
This built-in custom modifier will cause the price to be replaced by the sale price. Normally the plugin would list both a sale price and a regular price.
Mapped via Advanced Commands:
setAttributeDefault my_price as 0.00 PSalePriceIfDefined
mapAttribute my_price as g:price
Note: In recent versions (v126.96.36.199 and greater) it is possible to set valid to false at this stage to delete the product. In versions prior to this, the plugin was committed to write the product to the feed file.