Hello everyone,
I have noticed that the schema.org JSON-LD structured data is being added in the products page by using the SEO add-on. It’s really good that it’s already adding the most basic data to make the products visible in Google.
However, I was not able to find anywhere to add more fields or modify this data. I have tried to find a way to do this with My Changes add-on but it seems more complicated than this.
Basically, what I want to do is to add the shipping weight attribute to this structured data. Is there an easy way to do this. Or is there an add-on which allows me to modify or add more data to this json.
Hello ecomlabs,
Thank you very much for replying to this topic. Would you be able to give me an example code on how to add a hook and obtain the product weight? Or do you guys have an add-on which allows me achieve the thing that I am trying to do?
Thanks in advance
I’d like to clarify the template you may want to check: design/themes/responsive/templates/addons/seo/hooks/index/meta.post.tpl
And also the hook that you can use to extend the existing json-ld paramaters:
/**
* Executes when getting product Schema.org markup items, right before returning result,
* allows you to modify the created markup items.
*
* @param array $product_data Product data to get markup items from
* @param bool $show_price Whether product price must be shown
* @param string $currency Currency to get product price in
* @param array $markup_items Schema.org markup items
*/
fn_set_hook('seo_get_schema_org_markup_items_post', $product_data, $show_price, $currency, $markup_items);
Seems like “design/themes/responsive/templates/addons/seo/hooks/products/view_main_info.pre.tpl” is using the old itemprops microdata pattern and as of 4.11.4 is now deprecated. However I have tried adding itemprop only to my products in my website and I have tried it with Google’s https://search.google.com/test/rich-results test page but sadly those are not recognized. So it seems like my only option is to somehow modify or extend the JSON+LD data which is a the bottom of the page.
I am not an official add-on developer and have only tiny knowledge with php. So far I have only used my changes add-on to add some custom features to my website and to my products. So I have never used php hooks, only worked with tpl hooks.
Can I use this hook “seo_get_schema_org_markup_items_post” with my my changes add-on? Do you have a relevant documentation regarding that? Would you be able to help me getting and adding the “shipping_weight” for my products inside JSON+LD schema?
Sadly, I have no experience of php and I have no time to invest in this. If there is a modifiable solution or a ready add-on I would be willing to purchase. Thanks for the help anyway.