From a9e59992ff637f0e320ac0af63340b17063ddea3 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Sun, 29 May 2016 20:21:52 +0100 Subject: [PATCH] Support Brand and Model schema.org attributes --- db.sql | 2 ++ lib/App/Web/Oof.pm | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/db.sql b/db.sql index b753935..1cd64f3 100644 --- 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) ); diff --git a/lib/App/Web/Oof.pm b/lib/App/Web/Oof.pm index 0ecfd1b..186fb2f 100644 --- a/lib/App/Web/Oof.pm +++ b/lib/App/Web/Oof.pm @@ -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), -- 2.39.2