-
Notifications
You must be signed in to change notification settings - Fork 657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
商品詳細ページに構造化データを追加 #4986
商品詳細ページに構造化データを追加 #4986
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -214,6 +214,30 @@ file that was distributed with this source code. | |
$('.ec-modal').hide() | ||
}); | ||
</script> | ||
<script type="application/ld+json"> | ||
{ | ||
"@context": "https://schema.org/", | ||
"@type": "Product", | ||
"name": "{{ Product.name }}", | ||
"image": [ | ||
{% for img in Product.ProductImage %} | ||
"{{ app.request.schemeAndHttpHost }}{{ asset(img, 'save_image') }}"{% if not loop.last %},{% endif %} | ||
|
||
{% else %} | ||
"{{ app.request.schemeAndHttpHost }}{{ asset(no_image_product, 'save_image') }}" | ||
{% endfor %} | ||
], | ||
"description": "{{ Product.description_list | default(Product.description_detail) | striptags | replace({'\n': '', '\r': ''}) }}", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. descriptionは文字長の制限はありますか? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
仕様上の上限が見当たりませんでしたが、確かに全文出す必要はないと思いますので metaタグのdescription などで一般的な 300文字に丸めます There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. いくつかの文字種が期待通りに出力されないかもです。
そこまで厳密にする必要はないかもしれませんがいちおう。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
"sku": "{{ Product.code_min }}", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 商品コードは未設定の場合がありますが、skuは空でも問題ないですか? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sku は構造化データの仕様では「任意」でしたので、未設定の場合は出力しないよう変更しました |
||
"offers": { | ||
"@type": "Offer", | ||
"url": "{{ url('product_detail', {'id': Product.id}) }}", | ||
"priceCurrency": "{{ eccube_config.currency }}", | ||
"price": {{ Product.getPrice02IncTaxMin }}, | ||
"availability": "{{ Product.stock_find ? "InStock" : "OutOfStock" }}" | ||
} | ||
} | ||
</script> | ||
{% endblock %} | ||
|
||
{% block main %} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
画像のURLが以下のように出力されてました。
http://127.0.0.1:8080/html/upload/save_image/
no_image_productはtwigフィルタなので、以下のように渡してください
{{ asset(''|no_image_product, 'save_image') }}