price INT NOT NULL,
stock INT NOT NULL,
freepost BOOLEAN NOT NULL DEFAULT FALSE,
+ model TEXT,
+ brand TEXT,
CONSTRAINT positive_stock CHECK (stock >= 0)
);
sub product_to_schemaorg {
my ($include_url, %data) = @_;
my $stock = $data{stock} > 0 ? 'InStock' : 'OutOfStock';
+ my @extra;
+ push @extra, (brand => {'@type' => 'Brand', name => $data{brand}}) if $data{brand};
+ push @extra, (model => $data{model}) if $data{model};
+{
'@context' => 'http://schema.org/',
'@type' => 'Product',
name => $data{title},
image => "/static/fullpics/$data{product}-1.jpg",
description => $data{subtitle},
+ @extra,
offers => {
'@type' => 'Offer',
price => ($data{price} =~ s/(..)$/\.$1/r),