Jump to content

Products meta description problem in GSC PS 1.7.6.0 + classic-rocket


PanzerkampfPL

Recommended Posts

Hi there!
At GSC, I see as if products don't have a meta description.   
In /themes/classic-rocket/templates/_partials/microdata-jsonld.tpl is:
 


{/if}
{if isset($product) && $page.page_name == 'product'}
    <script type="application/ld+json">
    {
    "@context": "http://schema.org/",
    "@type": "Product",
    "name": "{$product.name}",
    "description": "{$page.meta.description}",
    "category": "{$product.category_name}",
    "sku": "{$product.reference}",


But unfortunately when I display the source of the product page this variable is empty:
image.png.63c1e15604249f8f75b6a80ac4170895.png

I noticed that if I create a "short description" in BO or write it in the "SEO" tab it inserts correctly. 
Is there any way to modify the code so that the "short description" is automatically substituted from the "long" description field? Taj how it is in the visual preview in BO?

image.png.c6d0cdb1d4c9a8e78fc7a374898c0379.png

Forgive such a simple question but I'm a noobie at modifying code.

Edited by Panzerkampf
cant paste rawe code? (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...

Hello @Panzerkampf

You can replace the 

"description": "{$page.meta.description}",

with the following code which will use the product description truncated to a 150 character max length text in case of the meta description is empty:

"description": "{if !empty($page.meta.description|strip:"")}{$page.meta.description|regex_replace:"/[\r\n]/" : " "}{elseif !empty($product.description|strip:"")}{$product.description|strip_tags:false|regex_replace:"/[\r\n]/" : ""|truncate:150 nofilter}{/if}",


I hope that I could help.

Have a nice day,
Leo.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...