Variation product SKU missing leading to Google shopping product price mismatch

#363435
  • Resolved Mohammed Salman
    Rank Math free

    Hello team
    In our E-commerce sites, majority of listings have variable products. When I switch on Woocommerce in Rankmath, it is generating Product schema for all the variants, but it is not generating Variation SKU.

    The problem I’m facing is explained in detail in the following link.
    https://inchoo.net/online-marketing/seo-vs-ppc-structured-data-markup-product-variants/

    Our products have seperate variant link as we are feeding data to Google merchant center.
    Google recommends the following fields to be in variant Product structured data.

    Title [title]
    Price [price]
    Color [color]
    Size [size]
    ID [id]
    Item group ID [item_group_id]

    Here ID refers to variation SKU and group ID refers to base SKU

    Source : https://support.google.com/merchants/answer/6324371#zippy=%2Cvariants

    I tried to add filter in rankmath.php but the vodes are visible in my page header.

    Kindly resolve my issue as I don’t want to install another schema plugin separately.

    Regards
    Salman.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.

    The method we use for the Schema markup is according to Google guidelines for the Product Schema: https://developers.google.com/search/docs/advanced/structured-data/product

    However, if you would like to modify that to show each offer and its data individually you can add and modify this filter to your particular needs:

    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
        if ( ! is_product() ) {
            return $entity;
        }
    
        $product = wc_get_product( get_the_ID() );
        if ( ! $product->is_type( 'variable' ) ) {
            return $entity;
        }
    
        $variations = $product->get_available_variations();
        if ( ! empty( $variations ) ) {
            $offers = [];
            foreach ( $variations as $variation ) {
                $price_valid_until = get_post_meta( $variation['variation_id'], '_sale_price_dates_to', true );
                $offers[] = [
                    '@type'           => 'Offer',
                    'description'     => strip_tags( $variation['variation_description'] ),
                    'price'           => $variation['display_price'],
                    'priceCurrency'   => get_woocommerce_currency(),
                    'availability'    => $variation['is_in_stock'] ? 'https://schema.org/InStock' : 'https://schema.org/OutOfStock',
                    'itemCondition'   => 'NewCondition',
                    'priceValidUntil' => $price_valid_until ? date_i18n( 'Y-m-d', $price_valid_until ) : '2025-12-31',
                    'url'             => $product->get_permalink(),
                    'sku'             => $variation['sku'],
                ];
            }
        }
    
        $entity['offers'] = $offers;
    
        return $entity;
    } );

    You can change each property according to your needs and remove any properties that you don’t require for the offers.

    The filter should be added to your active theme’s functions.php file. Here’s another way to apply the filter using the rankmath.php file:
    https://rankmath.com/kb/filters-hooks-api-developer/#adding-filters-and-hooks-in-rank-math-php

    Lastly, we also recommend that you read through this guide to learn more about the way Google tries to identify the price and the guidelines that you need to set for your prices on the website: https://support.google.com/merchants/answer/6324371

    I hope that helps.

    Thank you.

    Hello
    I added the code to functions.php file. The SKU got generated for individual variations.

    Value in Google feed
    [Item group ID] = Parent SKU
    [Item ID] = Variation SKU

    Structured data schema for Product generated by Rank Math

    SKU of Parent product
    SKU of Individual variation

    Value in the feed matches with Structured data generated, so all products got approved.

    This means that Rank Math should use the above code by default.

    Regards
    Salman.

    Hello,

    I am glad that this resolves your issue.

    We are constantly improving our plugin and we appreciate your feedback. We have noted your input and thank you so much for sharing it.

    Please do not hesitate to let us know if you need our assistance with anything else.

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

You must be logged in to reply to this ticket.