brotkrueml / schema

TYPO3 extension providing an API and view helpers for schema.org markup
https://extensions.typo3.org/extension/schema
GNU General Public License v2.0
32 stars 9 forks source link

Schema Markup for Offers of Product varians: Multiple Offers in one Offers with TypoScript #111

Closed aksenovaa closed 1 year ago

aksenovaa commented 1 year ago

I would like to get a mark-up for product variations according to the following scheme:

{
  "@context": "http://schema.org/",
  "@type": "Product",
  "name": "Clarks Falalala Shoes for Men",
  "image": "https://example.net/shoes/clarks-falalala.jpeg",
  "description": "A great comfortable walking shoe, carried in sizes 9-11, but now size 11 isn’t in stock",
  "offers": [ {
    "@type": "Offer",
    "sku": "QWERTYSHOE-9",
    "price": 45.99,
    "priceCurrency": "EUR",
    "availability": "InStock"
  },{
    "@type": "Offer",
    "sku": "QWERTYSHOE-10",
    "price": 45.99,
    "priceCurrency": "EUR",
    "availability": "InStock"
  },{
    "@type": "Offer",
    "sku": "QWERTYSHOE-11",
    "price": 45.99,
    "priceCurrency": "EUR",
    "availability": "OutOfStock"
  } ]
}

Current behavior

I'm trying to add a scheme with TypoScript, but I can't get multiple Offer nested under Offers :

offers.10 = SCHEMA
offers.10 {
    type = Offer
    properties {
        availability = https://schema.org/InStock
        priceValidUntil.stdWrap.data = date
        priceValidUntil.stdWrap.strtotime = + 1 year
        priceValidUntil.stdWrap.strftime = %Y-%m-%d
        priceSpecification = SCHEMA
        priceSpecification {
            type = UnitPriceSpecification
            properties {
                price = 1200
                maxPrice = 2000
                minPrice = 1200
                priceCurrency = RUB
                priceType = Стоимость печати офисных табличек на ПВХ пластике толщиной 3 мм за кв. м без постпечатной обработки (фрезеровка сложной формы, установка дистанционных держателей). Цены на печать табличек больших объемов оговариваются отдельно с менеджерами.
                unitText = кв. м
            }
        }
    }
}
offers.20 = SCHEMA
offers.20 {
    type = Offer
    properties {
        availability = https://schema.org/InStock
        priceValidUntil.stdWrap.data = date
        priceValidUntil.stdWrap.strtotime = + 1 year
        priceValidUntil.stdWrap.strftime = %Y-%m-%d
        priceSpecification = SCHEMA
        priceSpecification {
            type = UnitPriceSpecification
            properties {
                price = 10000
                maxPrice = 15000
                minPrice = 10000
                priceCurrency = RUB
                priceType = Стоимость печати офисных табличек на прозрачном акриле, оргстекле толщиной 3 мм за кв. м без постпечатной обработки (фрезеровка сложной формы, установка дистанционных держателей). Цены на печать табличек больших объемов оговариваются отдельно с менеджерами.
                unitText = кв. м
            }
        }
    }
}

But in the end, I can only get the markup for the last Offer, offers.20

{
    "@type": "Product",
    "@id": "https://art-poligrafy.ru/product/ukazateli-i-tablichki/office-tabs/#product",
    "aggregateRating": {
        "@type": "AggregateRating",
        "bestRating": "5",
        "description": "Рейтинг организации на основе отзывов о компании в Яндекс Бизнес",
        "ratingCount": "63",
        "ratingValue": "4.7",
        "url": "https://yandex.ru/profile/1096327740?intent=reviews"
    },
    "brand": {
        "@type": "Brand",
        "name": "Арт Полиграфия"
    },
    "description": "Изготовление офисных табличек, табличек для кабинетов в офис, табличек с названием организаций, именных офисных табличек на стол. Печать и изготовление офисных табличек из ПВХ пластика, табличек для офиса из оргстекла или акрила с дистанционными держателями.",
    "image": "https://art-poligrafy.ru/fileadmin/img/products/tabs/tabs-door-acril-docs_001.JPG",
    "name": "Изготовление табличек для офиса",
    "offers": {
        "@type": "Offer",
        "availability": "https://schema.org/InStock",
        "priceSpecification": {
            "@type": "UnitPriceSpecification",
            "maxPrice": "15000",
            "minPrice": "10000",
            "price": "10000",
            "priceCurrency": "RUB",
            "priceType": "Стоимость печати офисных табличек на прозрачном акриле, оргстекле толщиной 3 мм за кв. м без постпечатной обработки (фрезеровка сложной формы, установка дистанционных держателей). Цены на печать табличек больших объемов оговариваются отдельно с менеджерами.",
            "unitText": "кв. м"
        },
        "priceValidUntil": "2023-04-13"
    }
}
brotkrueml commented 1 year ago

What is offers? A COA? A PAGE?

A assume, the following is missing:

offers = COA
aksenovaa commented 1 year ago

hadn't thought of that The documentation didn't say that, it just did: Multiple values can also be assigned to one property using numeric keys. Example:

page.10 = SCHEMA page.10 { type = Organization properties { name = My Company sameAs { 10 = https://example.org/ 20.typolink { parameter = t3://page?uid=42 forceAbsoluteUrl = 1 returnLast = url } } } }

brotkrueml commented 1 year ago

At the end it is TypoScript ;-)

But: Why are you using TypoScript for that purpose? Every time, something changes, an integrator has to take action and adjust the structured data. Better would be to store the products in a database table and build the structured data with PHP. So an editor can adjust the products.

aksenovaa commented 1 year ago

These are specific services/goods: printing services, large format printing. It is not convenient to store them in the database - there are no precise definitions. Except for a price list. Some things I take from page parameters - images, some things I enter into variables by hand. Now instead of TS I have done the same on fluid. It works great.