Support Brand and Model schema.org attributes
authorMarius Gavrilescu <marius@ieval.ro>
Sun, 29 May 2016 19:21:52 +0000 (20:21 +0100)
committerMarius Gavrilescu <marius@ieval.ro>
Sun, 29 May 2016 19:21:52 +0000 (20:21 +0100)
db.sql
lib/App/Web/Oof.pm

diff --git a/db.sql b/db.sql
index b75393541c351806d651a4e6237061881a6b89a1..1cd64f348aaa22c90270d0ac75d196036ba9f12b 100644 (file)
--- a/db.sql
+++ b/db.sql
@@ -6,6 +6,8 @@ CREATE TABLE IF NOT EXISTS products (
        price    INT     NOT NULL,
        stock    INT     NOT NULL,
        freepost BOOLEAN NOT NULL DEFAULT FALSE,
+       model    TEXT,
+       brand    TEXT,
        CONSTRAINT positive_stock CHECK (stock >= 0)
 );
 
index 0ecfd1be76bcf9761d07b2bbb9a3ca46ff533484..186fb2fc4e931df41d8b01ac51efa4ed90b8b99e 100644 (file)
@@ -74,12 +74,16 @@ sub make_slug {
 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),
This page took 0.011891 seconds and 4 git commands to generate.