Use SKU for Global Identifier?

#148349
  • Resolved ac
    Rank Math free

    I am using the Product Schema and I am getting the “No global identifier provided (e.g., gtin, mpn, isbn) (optional)” warning from Google. In my case, the MPN for the product is exactly the same as the SKU for the product.

    Is there anyway in RankMath to populate the Global Identifier with the SKU for that product? Perhaps a function?

    Note that I do not use Woocommerce and would like to avoid adding that to solve this problem.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Roel John
    Rank Math business

    Hello,

    Thank you for contacting Rank Math.

    You can use filter hooks to add/edit the SKU in your product schema. Please check the sample code below.

    You need to add it to your functions.php in your theme files.

    
    /**
     * Filter to change the schema data.
     * Replace $schema_type with schema name like article, review, etc.
     * @param array $entity Snippet Data
     * @return array
     */
    add_filter( "rank_math/snippet/rich_snippet_product_entity", function( $entity ) {
    	$entity['sku'] = 'Your-Global-Indetifier';
    	return $entity;
    });
    

    Let us know if this helps.

    Looking forward to your update.

    Thank you.

    ac
    Rank Math free

    Thanks that helps. I changed it a bit to make it work for me:

    /**
     * Filter to change the schema data.
     * Replace $schema_type with schema name like article, review, etc.
     * @param array $entity Snippet Data
     * @return array
     */
    add_filter( "rank_math/snippet/rich_snippet_product_entity", function( $entity ) {
    	$entity['mpn'] = $entity['sku'];
    	return $entity;
    });
    Febby
    Rank Math free

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)

The ticket ‘Use SKU for Global Identifier?’ is closed to new replies.