Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add product schema in category list

Krzysztof Wolski06d038a3eaf0
diff --git a/saleor/static/js/components/categoryPage/ProductItem.js b/saleor/static/js/components/categoryPage/ProductItem.js
index 8c9ee7cf93..31eae53f98 100644
--- a/saleor/static/js/components/categoryPage/ProductItem.js
+++ b/saleor/static/js/components/categoryPage/ProductItem.js
@@ -9,15 +9,33 @@ class ProductItem extends Component {
product: PropTypes.object
};
+ getSchema = () => {
+ const { product } = this.props;
+ let data = {
+ "@context": "http://schema.org/",
+ "@type": "Product",
+ "name": product.name,
+ "image": product.thumbnailUrl,
+ "offers": {
+ "@type": "Offer",
+ "priceCurrency": product.price.currency,
+ "price": product.price.net,
+ }
+ };
+ return JSON.stringify(data);
+ };
+
render() {
const { product } = this.props;
+ let productSchema = this.getSchema();
return (
- <div className="col-6 col-md-4 product-list" itemScope itemType="https://schema.org/Product">
- <a itemProp="url" href={product.url}>
+ <div className="col-6 col-md-4 product-list">
+ <script type="application/ld+json">{productSchema}</script>
+ <a href={product.url}>
<div className="text-center">
<div>
- <img itemProp="image" className="img-responsive" src={product.thumbnailUrl} alt="" />
- <span className="product-list-item-name" itemProp="name" title={product.name}>{product.name}</span>
+ <img className="img-responsive" src={product.thumbnailUrl} alt="" />
+ <span className="product-list-item-name" title={product.name}>{product.name}</span>
</div>
<div className="panel-footer">
<ProductPrice price={product.price} availability={product.availability} />