src/WebBundle/Resources/views/Tile/ldjson.html.twig line 1

Open in your IDE?
  1. {% set imgs = [] %}
  2. {% if collection.interiors is defined %}
  3.     {% for int in collection.interiors %}
  4.         {% set imgs = imgs | merge(['"' ~ int.pathImg ~ '"']) %}
  5.     {% endfor %}
  6. {% endif %}
  7. {% if collection.interiorsSuitable is defined %}
  8.     {% for int in collection.interiorsSuitable %}
  9.         {% set imgs = imgs | merge(['"' ~ int.pathImg ~ '"']) %}
  10.     {% endfor %}
  11. {% endif %}
  12. {% set availability = 'https://schema.org/InStock' %}
  13. {% if collection.msg %}
  14.     {% set availability = 'https://schema.org/Discontinued' %}
  15. {% endif %}
  16. {% set settings = collection.settingsReact %}
  17. {% set materials = '' %}
  18. {% if settings is defined and settings.material is defined and settings.material.list is defined %}
  19.     {% for curMaterial in settings.material.list %}
  20.         {% set materials = materials ~ curMaterial.name %}
  21.         {% if not loop.last %}
  22.             {% set materials = materials ~ ', ' %}
  23.         {% endif %}
  24.     {% endfor %}
  25. {% endif %}
  26. {% set customerName = 'Customer' %}
  27. {% apply spaceless %}
  28. <script type="application/ld+json" rel="no">
  29. {
  30. "@context": "https://schema.org/",
  31. "@type": "Product",
  32. "mpn": "{{ collection.id }}",
  33. "sku": "{{ collection.code }}",
  34. "name": "{{ collection.header | striptags('') }}",
  35. {% if imgs | length > 1 %}
  36. "image": [{{ imgs | join(', ') | raw }}],
  37. {% else %}
  38. "image": {{ imgs | first | raw }},
  39. {% endif %}
  40. "description": "{{ meta.specs | raw }}",
  41. "countryOfOrigin": "{{ collection.factory.country.alias }}",
  42. "brand": {
  43. "@type": "Brand",
  44. "name": "{{ collection.factory.ActualName }}"
  45. },
  46. "material": "{{ materials }}",
  47. "offers": {
  48. "@type": "Offer",
  49. "priceCurrency": "{{ userCurrency() }}",
  50. "price": "{{ prMin(collection, {'currency': te.locale.getCur(), 'country': te.locale.getCurCountry()}) }}",
  51. "itemCondition": "https://schema.org/NewCondition",
  52. "availability": "{{ availability }}",
  53. "seller": {
  54. "@type": "Organization",
  55. "name": "Tile.Expert"
  56. },
  57. "url": "{{ app.request.getSchemeAndHttpHost() ~ path('app_collection', {'factoryUrl':  collection.factory.url, 'collectionUrl': collection.url}) }}"
  58. }
  59. {% if collection.reviews is defined and collection.reviews.count > 0 %}
  60. ,"aggregateRating": {
  61. "@type": "AggregateRating",
  62. "ratingValue": "{{ collection.reviews.percent.d }}",
  63. "reviewCount": "{{ collection.reviews.count }}",
  64. "bestRating": "5"
  65. },
  66. "review": [
  67. {% for k,review in collection.reviews.list %}
  68. {% if k != 0 %},{% endif %}
  69. {% if review.username is defined and review.username %}
  70. {% set customerName = review.username %}
  71. {% endif %}
  72. {
  73. "@type": "Review",
  74. "author": {
  75. "@type": "Person",
  76. "name": "{{ customerName }}"
  77. },
  78. "datePublished": "{{ review.date | date('Y-m-d') }}",
  79. "description": "{{ review.content }}",
  80. "reviewRating": {
  81. "@type": "Rating",
  82. "ratingValue": "{{ review.star }}",
  83. "bestRating": "5",
  84. "worstRating": "1"
  85. }
  86. }
  87. {% endfor %}
  88. ]
  89. {% endif %}
  90. }
  91. </script>
  92. {% endapply %}