Files
helper-functions/XMLtoGraphQL/stary.xslt
2025-12-04 14:58:52 +01:00

126 lines
5.8 KiB
HTML

<script type="application/json" id="blogRecommendedProducts">
[
<iaixsl:for-each select="page/cms_products/*">
{
"id": <iaixsl:value-of select="@id"/>,
"type": "<iaixsl:choose><iaixsl:when test="@product_type = 'product_item'">product</iaixsl:when><iaixsl:otherwise><iaixsl:value-of select="substring-after(@product_type, '_')"/>",</iaixsl:otherwise></iaixsl:choose>",
"code": "<iaixsl:value-of select="@code"/>",
"name": "<iaixsl:value-of select="name"/>",
"versionName": "<iaixsl:value-of select="@version_name"/>",
"description": "<iaixsl:value-of select="cleardescription"/>",
"link": "<iaixsl:value-of select="@link"/>",
"zones": [
<iaixsl:if test="@promo = 'true'">"promotion"<iaixsl:if test="@bestseller = 'true' or @new = 'true'">,</iaixsl:if></iaixsl:if>
<iaixsl:if test="@bestseller = 'true'">"bestseller"<iaixsl:if test="@new = 'true'">,</iaixsl:if></iaixsl:if>
<iaixsl:if test="@new = 'true'">"new"</iaixsl:if>
],
"icon": "<iaixsl:value-of select="icon"/>",
"iconSmall": "<iaixsl:value-of select="icon_small"/>",
"points": <iaixsl:choose><iaixsl:when test="price/@points &gt; 0"><iaixsl:value-of select="price/@points"/></iaixsl:when><iaixsl:otherwise>0</iaixsl:otherwise></iaixsl:choose>,
"price": {
<iaixsl:if test="/shop/rebatecode">"rebateCodeActive": true,</iaixsl:if>
"price": {
"gross": {
"value": <iaixsl:value-of select="price/@value"/>,
"formatted": "<iaixsl:value-of select="price/@price_formatted"/>"
}
},
"omnibusPrice": {
"gross": <iaixsl:choose><iaixsl:when test="price/@omnibus_price">{
"value": <iaixsl:value-of select="price/@omnibus_price"/>,
"formatted": "<iaixsl:value-of select="price/@omnibus_price_formatted"/>"
}</iaixsl:when><iaixsl:otherwise>null</iaixsl:otherwise></iaixsl:choose>
},
"omnibusPriceDetails": {
<iaixsl:if test="price/@omnibus_yousave_percent">
"youSavePercent": <iaixsl:value-of select="price/@omnibus_yousave_percent"/>,
"omnibusPriceIsHigherThanSellingPrice": <iaixsl:value-of select="price/@omnibus_price_is_higher_than_selling_price"/>
</iaixsl:if>
},
"max": {
"gross": <iaixsl:choose><iaixsl:when test="price/@maxprice">{
"value": <iaixsl:value-of select="price/@maxprice"/>,
"formatted": "<iaixsl:value-of select="price/@maxprice_formatted"/>"
}</iaixsl:when><iaixsl:otherwise>null</iaixsl:otherwise></iaixsl:choose>
},
"unit": {
"gross": <iaixsl:choose><iaixsl:when test="price/@price_unit">{
"value": <iaixsl:value-of select="price/@price_unit"/>,
"formatted": "<iaixsl:value-of select="price/@price_unit_formatted"/>"
}</iaixsl:when><iaixsl:otherwise>null</iaixsl:otherwise></iaixsl:choose>
},
"unitConvertedPrice": {
"gross": <iaixsl:choose><iaixsl:when test="price/@unit_converted_price">{
"value": <iaixsl:value-of select="price/@unit_converted_price"/>,
"formatted": "<iaixsl:value-of select="price/@unit_converted_price_formatted"/>"
}</iaixsl:when><iaixsl:otherwise>null</iaixsl:otherwise></iaixsl:choose>
},
<iaixsl:if test="price/@yousave_percent">"youSavePercent": <iaixsl:value-of select="price/@yousave_percent"/>,</iaixsl:if>
"beforeRebate": {
"gross": <iaixsl:choose><iaixsl:when test="price/@beforerebate">{
"value": <iaixsl:value-of select="price/@beforerebate"/>,
"formatted": "<iaixsl:value-of select="price/@beforerebate_formatted"/>"
}</iaixsl:when><iaixsl:otherwise>null</iaixsl:otherwise></iaixsl:choose>
}
},
"opinion": {
"rating": 0,
"count": 0
},
"category": {
"name": "<iaixsl:value-of select="category/@name"/>"
},
"awardedParameters": [
<iaixsl:for-each select="traits/trait[not(@groupid = preceding-sibling::trait/@groupid)]">
{
"id": "<iaixsl:value-of select="@groupid"/>",
"name": "<iaixsl:value-of select="@groupdescription"/>",
"description": "<iaixsl:value-of select="description"/>",
"values": [
<iaixsl:for-each select="../trait[@groupid = current()/@groupid]">
{
"id": "<iaixsl:value-of select="@traitid"/>",
"name": "<iaixsl:value-of select="@traitdescription"/>"
}<iaixsl:if test="last() != position()">,</iaixsl:if>
</iaixsl:for-each>
]
}<iaixsl:if test="last() != position()">,</iaixsl:if>
</iaixsl:for-each>
],
"sizes": [
<iaixsl:for-each select="sizes/size">
{
"id": "<iaixsl:value-of select="@type"/>",
"amount": <iaixsl:value-of select="@amount"/>
}<iaixsl:if test="last() != position()">,</iaixsl:if>
</iaixsl:for-each>
],
"enclosuresImages": [
<iaixsl:for-each select="enclosures/images/enclosure">
{
"position": <iaixsl:value-of select="@position"/>,
"type": "<iaixsl:value-of select="@type"/>",
"url": "<iaixsl:value-of select="@url"/>",
"width": <iaixsl:value-of select="@width"/>,
"height": <iaixsl:value-of select="@height"/>,
"iconUrl": "<iaixsl:value-of select="@icon"/>",
"iconWidth": <iaixsl:value-of select="@icon_width"/>,
"iconHeight": <iaixsl:value-of select="@icon_height"/>,
"mediumUrl": "<iaixsl:value-of select="@medium"/>",
"mediumWidth": <iaixsl:value-of select="@medium_width"/>,
"mediumHeight": <iaixsl:value-of select="@medium_height"/>
}<iaixsl:if test="last() != position()">,</iaixsl:if>
</iaixsl:for-each>
],
"producer": {
"id": "<iaixsl:value-of select="substring-before(substring-after(firm/@icon, '/gfx/projector/'), '_1.jpg')"/>",
"name": "<iaixsl:value-of select="firm/@name"/>",
"link": "<iaixsl:value-of select="firm/@productslink"/>",
"searchIcons": {
"icon": "<iaixsl:value-of select="firm/@icon"/>"
}
}
}<iaixsl:if test="last() != position()">,</iaixsl:if>
</iaixsl:for-each>
]
</script>