Skip to content

Commit

Permalink
product microdata ok
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmassen committed Dec 17, 2017
1 parent c2adc6d commit 9f40aba
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 13 deletions.
20 changes: 18 additions & 2 deletions blueprints/seo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,17 @@ form:
header.product.category:
type: text
label: Category of the product
header.product.ratingValue:
type: range
label: Star Rating
help: Choose a value between 0 and 5 which should be the average ratings for your product. Make sure the value is consistent with your actual reviews.
validate:
min: 0
max: 5
step: 0.1
header.product.reviewCount:
type: number
label: Number of reviews you used for calculating your rating.
header.product.brand:
type: text
label: Product Brand
Expand All @@ -588,6 +599,7 @@ form:
header.product.image:
type: list
label: Add an image for this product
style: vertical
btnLabel: Add image
fields:
.productimg:
Expand All @@ -602,6 +614,7 @@ form:
label: Add an offer for this product
btnLabel: Add offer
controls: both
style: vertical
fields:
.offer_availability:
type: select
Expand All @@ -620,8 +633,11 @@ form:
placeholder: "e.g: 19.99 (no currency symbol)"
.offer_validFrom:
type: datetime
label: Offer is valid from
type: text
label: Offer is valid from (optional)
.offer_validUntil:
type: datetime
label: Offer is valid until (optional)

.offer_priceCurrency:
type: select
label: PLUGIN_SEO.PRICE_CURRENCY
Expand Down
34 changes: 23 additions & 11 deletions seo.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,26 +457,38 @@ public function onPageInitialized()
};

};
$offers = $page->header()->product['addoffer'];
foreach ($offers as $key => $value){
$offer[$key] = [
'@type' => 'Offer',
'priceCurrency' => @$offers[$key]['offer_priceCurrency'],
'price' => @$offers[$key]['offer_price'],
'validFrom' => @$offers[$key]['offer_validFrom'],
'priceValidUntil' => @$offers[$key]['offer_validUntil'],
'availability' => @$offers[$key]['offer_availability'],
];
};


}
$microdata[] = [
'@context' => 'http://schema.org',
'@type' => 'Product',
'name' => @$page->header()->product['name'],

'address' => [
'@type' => 'PostalAddress',
'addressLocality' => @$page->header()->restaurant['address_addressLocality'],
'addressRegion' => @$page->header()->restaurant['address_addressRegion'],
'streetAddress' => @$page->header()->restaurant['address_streetAddress'],
'postalCode' => @$page->header()->restaurant['address_postalCode'],
],
'servesCuisine' => @$page->header()->restaurant['servesCuisine'],
'category' => @$page->header()->product['category'],
'brand' => @$page->header()->product['brand'],
'brand' => [
'@type' => 'Thing',
'name' => @$page->header()->product['brand'],
],
'offers' => $offer,
'description' => @$page->header()->product['description'],
'image' => @$productimage
'image' => @$productimage,
'aggregateRating' => [
'@type' => 'AggregateRating',
'ratingValue' => @$page->header()->product['ratingValue'],
'reviewCount' => @$page->header()->product['reviewCount'],

]
];


Expand Down

0 comments on commit 9f40aba

Please sign in to comment.