• Closed by: Fred
  • Closed on: 03.01.20, 15:33
  • Reason: Closed
  • Comment: Glad to help!

Ticket #16378 - Schema Structured Data - product.tpl

I’m tidying up and correcting Structured-data according to the google tool:
https://search.google.com/structured-data/testing-tool/u/0/

You are showing me good Home and Categories. But on the Products Page it doesn’t show me the product from the Web and it leaves me separate offer, review and aggregateRating.

Can you help me? For me pagebuilder calls are confusing.

(EVERYTHING I’M DOING IS IN DEVELOPMENT)

dev.tiendahippie.co.es

Sample capture: https://dev.tiendahippie.es/es/camisetas-tops-largos-y-blusas/1702-9503-camiseta-patchwork.html#/55-talla-s_36_38

Thank you

Attachments:

schema.png (124.9 KiB)

Comments

Fred 04 Dec 2019, 21:23

Try to add the code below into the file /themes/alysum/templates/mobile/catalog/product.tpl right after the line:
{extends file=’mobile/layouts/layout-main.tpl’}


{block name='head_scripts' append}
<script type="application/ld+json">
{literal}
{
  "@context": "https://schema.org/",
  "@type": "Product",
  "name": "{/literal}{$product.name}{literal}",
  "image": "{/literal}{$product.cover.large.url}{literal}",
  "description": "{/literal}{$product.description_short|strip_tags:false}{literal}",
  "mpn": "{/literal}{$product.reference}{literal}",
  "sku": "{/literal}{$product.reference_to_display}{literal}",
  "brand": {
      "@type": "Brand",
      "name": "{/literal}{$product.manufacturer_name}{literal}"
  },
  {/literal}{if (isset($rating.grade))}{literal}
  "aggregateRating": {
      "@type": "AggregateRating",
      "ratingValue": "{/literal}{$rating.grade}{literal}",
      "reviewCount": "{/literal}{$rating.reviewCount}{literal}",
      "worstRating": "0",
      "bestRating": "5"
  },
  "review": {
    "@type": "Review",
    "reviewRating": {
      "@type": "Rating",
      "ratingValue": "{/literal}{$rating.grade}{literal}",
      "bestRating": "5",
      "worstRating": "0"
    },
    "author": {
      "@type": "Person",
      "name": "Fred Benson"
    }
  },
  {/literal}{/if}{literal}
  "offers": {
    "@type": "Offer",
    "url": "{/literal}{$product.link}{literal}",
    "priceCurrency": "{/literal}{$currency.sign}{literal}",
    "price": "{/literal}{$product.price_amount}{literal}",
    {/literal}{if isset($product.available_for_order)}{literal}
    "availability": "https://schema.org/InStock",
    {/literal}{else}{literal}
    "availability": "https://schema.org/OutOfStock",
    {/literal}{/if}{literal}
    {/literal}{if isset($product.embedded_attributes.condition) && ($product.embedded_attributes.condition == 'new')}{literal}
    "itemCondition": "https://schema.org/NewCondition",
    {/literal}{/if}{literal}
    {/literal}{if isset($product.embedded_attributes.condition) && ($product.embedded_attributes.condition == 'used')}{literal}
    "itemCondition": "https://schema.org/UsedCondition",
    {/literal}{/if}{literal}
    "priceValidUntil": "{/literal}{$smarty.now|date_format:"%Y"+1}-{$smarty.now|date_format:"%m-%d"}{literal}"
  }
}
{/literal}
</script>
{/block}
Alexandro Galussio 05 Dec 2019, 11:39

Hey, Fred, that’s what you’re putting on mobile. I was on desktop, then I’ll have to do it with Amp so it’s still good for me.
On desktop \template\catalog After line: {extends file=$layout}?

Fred 06 Dec 2019, 13:39

On desktop product page file is \template\catalog\product.tpl and yes, after the line

{extends file=$layout}
Alexandro Galussio 06 Dec 2019, 16:28

I already put the code and empty the cache but it still does not put the product of the web and separate puts the offer and the rating.
Send screenshot

Attachments:

schema.png (169.1 KiB)
Fred 07 Dec 2019, 14:23

Try to enable product comments module to eliminate this error https://take.ms/FzAuc

Alexandro Galussio 09 Dec 2019, 11:45

Look again at the screenshot I sent you before and you will see the following errors:
1- The main product of the page does not appear in schema. The 16 products that appear are products in the same category.
2- Offer, Review and Aggregate Rating appears but outside products. It must be because the main product is not there.

Do you understand what I explain?
Thank you

Fred 10 Dec 2019, 12:15
Alexandro Galussio 10 Dec 2019, 12:45

Hi Fred, in English is not review, only in Spanish will you be able to prove it.

https://search.google.com/test/rich-results?id=VyFbK-F4K8bS1e5oD0T2Dg

Attachments:

schema-test.png (104.5 KiB)
Fred 11 Dec 2019, 13:09

That is an optional attribute https://take.ms/tVVu2 and it depends on review what you have for current product

Alexandro Galussio 11 Dec 2019, 14:22

Hello Fred, but the problem is different. I have the review but neither the review nor the product is being shown.
Look at the image above. Remember it must be in Spanish (the review is in Spanish)

Fred 12 Dec 2019, 11:41

As I can see you have some another comment module https://take.ms/ELzaP and that module has to add review parameters for Google Rich Snippet

Alexandro Galussio 12 Dec 2019, 19:11

Hello Fred, but the problem is different. I have the review but neither the review nor the product is being shown.
Look at the image above. Remember it must be in Spanish (the review is in Spanish)

The problem is that it does not display the product with the offer and comment.

Fred 12 Dec 2019, 21:27

As I wrote you before that module (your product comments) should provide such information, not the theme

Alexandro Galussio 13 Dec 2019, 12:06

Fred, the problem is not with the comment module. The product and the offer are also missing.
And the rating and review module works because in schema you can see it. What is missing is the product.

Fred 15 Dec 2019, 12:42

Please check out source code of native prestashop productcomments module https://github.com/PrestaShop/productcomments/blob/master/views/templates/hook/product-list-reviews.tpl Here is the screenshot to show you what I mean https://take.ms/iqh0m

Alexandro Galussio 16 Dec 2019, 11:33

Hello Fred, the product you see today was a development product and has no comments. I’ve read how it should appear so I’m still trying to explain the error.

Please look at the following product (without modifying the code that is from the production server)

This product has Offer and Rating

https://www.tiendahippie.es/es/abrigos-hippie-xl/1153-7597-abrigo-negro-bordado-etnico.html#/68-talla-xl_46

I use the tool that Google technical support told me to use:
https://search.google.com/structured-data/testing-tool/u/0/

Attachments:

error-schema16-12.png (166.2 KiB)
Fred 16 Dec 2019, 17:59

Write you once more.
- You are using your own product comments module
- that module has to add missing parameter
Nothing more here

Alexandro Galussio 16 Dec 2019, 18:04

Fred, I understand what you’re saying, but you don’t understand what I’m writing.
The problem is not that there is a lack of data in the module!
If you read what I show you for example you have the price offer without product! This has nothing to do with the review module.

Fred 16 Dec 2019, 19:00

Sorry, but I still can’t understand.
As I can see there is only one error https://take.ms/38yuU and that parameter has to be provided by product comments module

Alexandro Galussio 17 Dec 2019, 13:28

The problem is that the product you are testing DOES NOT APPEAR IN SCHEMA.
The 5 elements that appear as a product are those of products in the same category.
The error is that the labels of the main product of the website you are testing are not there.

The “coat-black-embroidered-ethnic.html” is not in SCHEMA.
The mistake is that it is not ! And it is the main product

Is the error understood?

Attachments:

product-schema.png (169.8 KiB)
Fred 18 Dec 2019, 12:55

Here is a link to Classic theme https://s1.demo.opensourcecms.com/prestashop/blouses/2-7-blouse.html#/1-size-s/11-color-black you can test it out and make sure it’s parsed by google the same as our theme.

Alexandro Galussio 18 Dec 2019, 14:32

Hello, there you can put thema in classic at dev. and remove Maintenance to test and send you the schema capture.
There it works well but not with the Alysum theme, because the main product (in this case embroidered coat) in the classic theme is there and not in Alysum.

Attachments:

schema-clasic.png (186.1 KiB)
Fred 19 Dec 2019, 15:04

I just added missed code to the product page https://take.ms/uH8Aa please check it out now