Google Shoppingのmerchant centerに勝手に登録してくれて、Google Shoppingに出てくるようになるので便利です。
今回は2026年7月に更新された商品カテゴリのマークアップについて
Schema.orgのProduct > CategoryはGoogle Product Codeを指定する
inCodeSetにhttps://www.google.com/basepages/producttype/taxonomy-with-ids.ja-JP.txtを指定するのがミソです。
このURL探すのに少し時間かかった…
どのGoogle Product Codeが適しているか?はMerchant Centerとかで確認してDBのカテゴリテーブルに格納するなりなんなりしてテンプレートに変数として渡してあげてください。標準(カスタマイズ無し)では出力できません。
Smarty(2系)
<!--{if $category_text and $category_code}-->
,"category": {
"@type": "CategoryCode",
"name": "<!--{$category_text|escape}-->",
"codeValue": "<!--{$category_code|escape}-->",
"inCodeSet": "https://www.google.com/basepages/producttype/taxonomy-with-ids.ja-JP.txt"
}
<!--{/if}-->
twig(4系)
{% if category_text and category_code %}
,"category": {
"@type": "CategoryCode",
"name": "{{$category_text}}",
"codeValue": "{{category_code}}",
"inCodeSet": "https://www.google.com/basepages/producttype/taxonomy-with-ids.ja-JP.txt"
}
{% endif %}
EC-CUBEの商品カテゴリはproduct_typeに記述する
"product_type": "ロッド > PENN"
EC-CUBEのテンプレートに書くならこんな感じ
Smarty(2系)
<!--{assign var=product_typet value='' }-->
<!--{section name=s loop=$arrRelativeCat[0]}-->
<!--{assign var=product_type value="`$product_type``$arrRelativeCat[0][s].category_name|escape`"}-->
<!--{if !$smarty.section.s.last}-->
<!--{assign var=product_type value="`$product_type` > "}-->
<!--{/if}-->
<!--{/section}-->
<!--{if $product_type != '' }-->
,"product_type": "<!--{$product_type}-->"
<!--{/if}-->
Twig(4系)
,"product_type": "{% for ParentCategory in ProductCategory.Category.path %}
{{ ParentCategory.name }}{% if not loop.last %} > {% endif %}
{% endfor %}"
