Schema.org isConsumableFor Property in JSON

Viewed 112

Trying to sort out how to use the schema.org property isConsumableFor with JSON. I set the main product as "Raspberry Pi 4" and the isConsumableFor product "Power Supply".

The JSON snippet is built for "Raspberry Pi 4":

{
    "@context":"http://schema.org/",
    "@type":"Product",
    "name":"Raspberry Pi 4",
    "image":[
        "raspberry-pi-4-model-b.jpg",
        "raspberry-pi-4-model-b-2.jpg",
    ],
    "description":"Raspberry Pi 4 ...",
    "offers":{
        "@type":"AggregateOffer",
        "offerCount":1,
        "highPrice":"40.00 ",
        "lowPrice":"40.00 ",
        "priceCurrency":"EUR",
        "offers":[
            {
                "@type":"Offer",
                "priceCurrency":"EUR",
                "priceValidUntil":"2019-11-09T21:50:32+01:00",
                "url":"Raspberry-Pi-4-Model-B",
                "price":"40.00 ",
                "itemCondition":"http://schema.org/New",
                "availability":"http://schema.org/InStock",
            }
        ]
    }
}

On the page of Raspberry Pi 4 where do I have to kick the property "isConsumableFor"? To Raspberry Pi 4 or to Power Supply?

{
    "@context": "http://schema.org/",
    "@type": "Product",
    "isConsumableFor":{ 
        "@context":"http://schema.org/",
        "@type":"Product",
        "name":"Raspberry Pi 4",
        "url":"example.com",
    },
}

or that way but if there are more consumable products available for Raspberry Pi 4 than it will repeat all the time the Raspberry Pi 4 where one time should be enough for all accessories:

{
    "@context":"http://schema.org/",
    "@type":"Product",
    "name":"Power Supply",
    "image":[
        "psu.jpg",
        "psu-2.jpg",
    ],
    "description":"Power Supply ...",
    "offers":{
        "@type":"AggregateOffer",
        "offerCount":1,
        "highPrice":"8.00 ",
        "lowPrice":"8.00 ",
        "priceCurrency":"EUR",
        "offers":[
            {
                "@type":"Offer",
                "priceCurrency":"EUR",
                "priceValidUntil":"2019-11-09T21:50:32+01:00",
                "url":"powersupply",
                "price":"8.00 ",
                "itemCondition":"http://schema.org/New",
                "availability":"http://schema.org/InStock",
            }
        ]
    },
    "isConsumableFor":{ 
        "@context":"http://schema.org/",
        "@type":"Product",
        "name":"Raspberry Pi 4",
    }
}
1 Answers

Modifying your JSON-LD to the below will make it valid as far as the Structured Data Testing Tool is concerned, but there are a couple of caveats to this approach depending on how you generate your content.

I believe the best approach would be to take advantage of a global identifier (id):

Raspberry Pi

{
    "@context":"http://schema.org/",
    "@type":"Product",
    "id":"https://example.com/raspberrypi4",
    "name":"Raspberry Pi 4",
    "price":"49"
    ...
}

Power Supply

{
    "@context":"http://schema.org/",
    "@type":"Product",
    "name":"Power Supply",
    "image":[
        "psu.jpg",
        "psu-2.jpg"
    ],
    "description":"Power Supply ...",
    "offers":{
        "@type":"AggregateOffer",
        "offerCount":1,
        "highPrice":"8.00 ",
        "lowPrice":"8.00 ",
        "priceCurrency":"EUR",
        "offers":[
            {
                "@type":"Offer",
                "priceCurrency":"EUR",
                "priceValidUntil":"2019-11-09T21:50:32+01:00",
                "url":"powersupply",
                "price":"8.00 ",
                "itemCondition":"http://schema.org/New",
                "availability":"http://schema.org/InStock"
            }
        ]
    },
    "isConsumableFor":{ 
        "@type":"Product",
        "name":"Raspberry Pi 4",
        "id":"https://example.com/raspberrypi4",
        "offers":[{
            "@type":"Offer",
            "price":"49"
        }]
    }
}

As you can see because isConsumableFor requires a Product - that Product will still require offers, Review, or aggregateRating - so you would at least need to provide one of those properties (in this example I'm using Offer with price).

Unfortunately isConsumableFor is not very well documented on schema.org - and as of this this writing - this SO question is actually in the top four Google results for the property.

Personally I feel requiring an id or url for a nested Product should appease the requirements for Offer/aggregateRating/Review. I chalk it up to the fact that Schema is still ever growing.

With that said, the larger question might be - What are you using this Schema for? If you're looking to use it to improve Google results - I personally believe you won't find much benefit, regardless of how you use it. If you're trying to connect your data through another system via JSON-LD, then I wouldn't take the Structured Data Testing tool too seriously.

Related