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

Open in your IDE?
  1. {% if slider.type == 'a' %}
  2. {% set curId = slider.elementId %}
  3. {% set curElement = slider.elements[curId] %}
  4. {% set curElementName = '' %}
  5. {% if curElement.alternateName is defined and curElement.alternateName %}
  6. {% set curElementName = curElement.alternateName %}
  7. {% elseif curElement.name is defined and curElement.name %}
  8. {% set curElementName = curElement.name %}
  9. {% endif %}
  10. {% set curElInitPrice = curElement.discountsAmount %}
  11. {% if curElInitPrice is defined and curElInitPrice[0] is defined and curElInitPrice[0].price is defined %}
  12. {% set pCount = 1 %}
  13. {% if slider.measureGb %}
  14.     {% if curElement.packagingCountFt %}
  15.         {% set pCount = curElement.packagingCountFt %}
  16.     {% elseif curElement.packagingCount %}
  17.         {% set pCount = curElement.packagingCount %}
  18.     {% elseif curElement.packagingCountPC %}
  19.         {% set pCount = curElement.packagingCountPC %}
  20.     {% endif %}
  21. {% else %}
  22.     {% if curElement.packagingCount %}
  23.         {% set pCount = curElement.packagingCount %}
  24.     {% elseif curElement.packagingCountPC %}
  25.         {% set pCount = curElement.packagingCountPC %}
  26.     {% endif %}
  27. {% endif %}
  28. {% set curPrice = (pCount * curElInitPrice[0].price) | floatSing %}
  29. {% if userLocale() != 'en' %}
  30.     {% set curPrice = te.replaceStr('.', '', curPrice) %}
  31.     {% set curPrice = te.replaceStr(',', '.', curPrice) %}
  32. {% else %}
  33.     {% set curPrice = te.replaceStr(',', '', curPrice) %}
  34. {% endif %}
  35. {% if userLocale() == 'ru' %}
  36.     {% set curPrice = te.replaceStr(' ', '', curPrice) %}
  37. {% endif %}
  38. {% set colors = '' %}
  39. {% if curElement.colors is defined %}
  40.     {% for color in curElement.colors %}
  41.         {% set colors = colors ~ color.name %}
  42.         {% if not loop.last %}
  43.             {% set colors = colors ~ ', ' %}
  44.         {% endif %}
  45.     {% endfor %}
  46. {% endif %}
  47. {% set patterns = '' %}
  48. {% if curElement.motivs is defined %}
  49.     {% for motiv in curElement.motivs %}
  50.         {% set patterns = patterns ~ motiv.name %}
  51.         {% if not loop.last %}
  52.             {% set patterns = patterns ~ ', ' %}
  53.         {% endif %}
  54.     {% endfor %}
  55. {% endif %}
  56. {% set availability = 'https://schema.org/InStock' %}
  57. {% if slider.suspended %}
  58.     {% set availability = 'https://schema.org/OutOfStock' %}
  59. {% endif %}
  60. {% apply spaceless %}
  61. <script type="application/ld+json">
  62. {
  63. "@context": "https://schema.org/",
  64. "@type": "Product",
  65. "mpn": "{{ curId }}",
  66. "sku": "{{ curElement.code }}",
  67. "name": "{{ curElementName }}",
  68. "image": ["{{ te.replaceStr('\\', '/', curElement.pathImg) }}"],
  69. "description": "{{ meta.description | raw }}",
  70. "brand": {
  71. "@type": "Brand",
  72. "name": "{{ curElement.collection.factory.name }}"
  73. },
  74. "color": "{{ colors }}",
  75. "material": "{{ curElement.material.name }}",
  76. {% if curElement.motivs | length > 0 %}
  77.     "pattern": "{{ patterns }}",
  78. {% endif %}
  79. "width": "{{ curElement.width }}",
  80. "height": "{{ curElement.height }}",
  81. "offers": {
  82. "@type": "Offer",
  83. "priceCurrency": "{{ userCurrency() }}",
  84. "price": "{{ curPrice }}",
  85. "itemCondition": "https://schema.org/NewCondition",
  86. "availability": "{{ availability }}",
  87. "seller": {
  88. "@type": "Organization",
  89. "name": "Tile.Expert"
  90. },
  91. "url": "{{ app.request.uri }}"
  92. }
  93. }
  94. </script>
  95. {% endapply %}
  96. {% endif %}
  97. {% endif %}