Delivering supply chain confidence
Editorial: INTERNATIONAL ORGANIZATION FOR STANDARDIZATION
INTERNATIONAL ORGANIZATION FOR STANDARDIZATION
Se ha producido un error al procesar la plantilla.
The following has evaluated to null or missing:
==> getProductCategories(channelId, productId) [in template "34352066712900#33336#null" at line 13, column 30]
----
Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----
----
FTL stack trace ("~" means nesting-related):
- Failed at: #assign categoriesProduct = getProduc... [in template "34352066712900#33336#null" at line 13, column 1]
----
1<#-- Variables -->
2<#assign channelResponse = restClient.get("/headless-commerce-delivery-catalog/v1.0/channels?filter=name eq 'Aenor Tienda'")>
3<#assign channel = channelResponse.items[0]>
4<#assign channelId = channel.id>
5<#assign product = getProduct(channelId, CPDefinition_cProductId.getData()) />
6
7<#-- Product data -->
8<#assign displayDateProduct = CPDefinition_displayDate.getData() />
9<#assign productId = product.productId />
10<#assign cpDefinitionId = product.id />
11<#assign productERC = product.externalReferenceCode />
12
13<#assign categoriesProduct = getProductCategories(channelId, productId) />
14<#assign hasProductCategoriaTipoEntidadLibro = isVocabularyNameIntoCategories(categoriesProduct, 'entity type', 'libro') />
15<#assign hasProductCategoriaTipoEntidadNorma = isVocabularyNameIntoCategories(categoriesProduct, 'entity type', 'norma') />
16<#assign hasProductCategoriaTipoEntidadColeccionTematica = isVocabularyNameIntoCategories(categoriesProduct, 'entity type', 'coleccion tematica') />
17
18
19
20<#-- Functions -->
21<#function getProduct channelId productId>
22 <#return restClient.get("/headless-commerce-delivery-catalog/v1.0/channels/${channelId}/products/${productId}")>
23</#function>
24
25
26<#function getProductCategories channelId productId>
27 <#return restClient.get("/headless-commerce-delivery-catalog/v1.0/channels/${channelId}/products/${productId}/categories?sort=vocabulary").items>
28</#function>
29
30
31<#function isVocabularyNameIntoCategories categories vocabulary name>
32 <#assign found = false />
33
34 <#if categories?has_content && vocabulary?has_content && name?has_content>
35
36 <#assign vocabNorm = normalize(vocabulary) />
37 <#assign nameNorm = normalize(name) />
38
39 <#list categories as category>
40 <#if !found>
41 <#assign catVocabNorm = normalize(category.vocabulary) />
42 <#assign catNameNorm = normalize(category.name) />
43
44 <#if catVocabNorm == vocabNorm && catNameNorm == nameNorm>
45 <#assign found = true />
46 </#if>
47 </#if>
48 </#list>
49
50 </#if>
51
52 <#return found>
53</#function>
54
55
56<#function normalize text onlyAccents = false>
57 <#-- proteger null -->
58 <#if !text?has_content>
59 <#return "">
60 </#if>
61
62 <#assign t = text />
63
64 <#-- quitar acentos -->
65 <#assign t = t
66 ?replace("á","a")?replace("é","e")?replace("í","i")
67 ?replace("ó","o")?replace("ú","u")?replace("ü","u")
68 ?replace("ñ","n")
69 ?replace("Á","A")?replace("É","E")?replace("Í","I")
70 ?replace("Ó","O")?replace("Ú","U")?replace("Ü","U")
71 ?replace("Ñ","N")
72 />
73
74 <#-- si NO es solo acentos, normalización completa -->
75 <#if !onlyAccents>
76 <#assign t = t?lower_case />
77 <#assign t = t?trim />
78 <#assign t = t?replace("\\s+", " ", "r") />
79 </#if>
80
81 <#return t>
82</#function>
83
84
85<#-- HTML -->
86<#if hasProductCategoriaTipoEntidadLibro>
87 <div id="ecom-libro-price" class="container ecom-libro">
88
89 <aside class="purchase-box">
90
91 <div class="price-header">
92 <#if product.externalReferenceCode != "0001000">
93 <p class="old-price-block">
94 <span class="old-price">00,00 €</span>
95 <span class="discount">0</span>
96 </p>
97 </#if>
98
99 <p class="price">00,00 €</p>
100 <p class="note">${languageUtil.get(locale, "ecom-precio_sin_iva_gastos")}</p>
101
102 <!-- Para el libro "CDU online en español" no se muestra esta información -->
103 <#if product.externalReferenceCode != "0001000">
104 <div class="info-box-book">
105 <div class="info-text">
106 <div class="isbn"><span class="info-icon">i</span>ISBN:<span class="isbn-value"> 000-00-000</span><br/></div>
107 <div class="details"><span class="detail-year-published">000</span> – <span class="detail-pages">000</span> ${languageUtil.get(locale, "ecom-paginas")}</div>
108 </div>
109 </div>
110 </#if>
111 </div>
112
113 <!-- Para el libro "CDU online en español" se muestra mensaje no disponble-->
114 <#if product.externalReferenceCode != "0001000">
115 <div class="selectors">
116
117 <!-- Cantidad -->
118 <div class="qty">
119 <input type="number" min="1" value="1">
120 </div>
121
122 <!-- Selectores language y format -->
123 <div class="selector">
124 <div data-productid="${productId}" data-erc="${productERC}" class="pb-0 selectors selector-language_format"></div>
125 </div>
126
127 </div>
128
129 <button class="buy-btn btnae-- btnae--secondary animated-button disabled" disabled>${languageUtil.get(locale, "ecom-add_cart")}</button>
130 <#else>
131 <div class="py-2 px-3">
132 ${languageUtil.get(locale, "ecom-product_not_available")}
133 </div>
134 </#if>
135 </aside>
136 </div>
137</#if>










