From: Marius Gavrilescu Date: Sun, 29 May 2016 19:21:52 +0000 (+0100) Subject: Support Brand and Model schema.org attributes X-Git-Tag: 0.000_008~4 X-Git-Url: http://git.ieval.ro/?p=app-web-oof.git;a=commitdiff_plain;h=a9e59992ff637f0e320ac0af63340b17063ddea3 Support Brand and Model schema.org attributes --- 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),