Use Brand Names from another column

#767680
  • Resolved Ayan
    Rank Math free

    Hi,

    I am using a plugin which through which I define the brand names of products in woocommerce. The plugin has created its own custom column in the database which has the brand details.

    I sell multiple products from multiple brands. How do I enable Rank Math to recognize brand from the column of the database where the brand details are stored?

    Column name (from export import woocommerce products) = ‘Brands’

    I know that this code (https://rankmath.com/kb/filters-hooks-api-developer/#add-brand-name) can be used to create a custom brand name and assign it to products. But that’s only helpful if I sell a single brand which is not the case with me.

    Please help. Thanks!

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

    Thank you for reaching out to us with your query about using brand names from another column in your WooCommerce store with Rank Math.

    To enable Rank Math to recognize brand names from a custom column in your database, you can follow these steps:

    1. Create a Custom Brand Name: You can use the provided code snippet from this link to create a custom brand name and assign it to products. However, since you sell products from multiple brands, you will need to modify the code to dynamically fetch the brand details from your ‘Brands’ column in the database.

    2. Modify the Code: You will need to customize the code snippet to fetch the brand details from your ‘Brands’ column in the database and assign them to the respective products. This customization may require some coding knowledge or assistance from a developer familiar with PHP and WordPress.

    3. Testing: Once you have modified the code to fetch brand details from your custom column, you can test it by running your website through the Google Structured Data Testing Tool to ensure that the brand names are being correctly added to your product schema.

    If you encounter any difficulties or need further assistance while implementing this customization, please feel free to reply to this ticket, and our support team will be happy to assist you further.

    Thank you for using Rank Math!

    Sources:
    How to Use Brand Names on Your WooCommerce Store » Rank Math
    Google Search Console Missing Field Warning » Rank Math
    Setting a Custom Brand for Your WooCommerce Store with Rank Math » Rank Math
    Setting a Custom Brand for Your WooCommerce Store with Rank Math » Rank Math
    How to Use Product Schema for WooCommerce Products » Rank Math

    Ayan
    Rank Math free

    Hi, the above answer is relevant if I am selling a single Brand product, but since that is not the case, I will request for further help. Thanks!

    Point 2 mentioned above is what I require. can you help please?

    Hello,

    You can use that filter to add your brand names to your Product schema dynamically.

    You can reach out to the plugin you’re using to define brand names and ask them to let you know what the custom field for that brand is – and then you can use that in the filter instead of ‘Rank Math’

    Here’s an example code you can use as a guide:

    /**
     * Filter to add Brand Name for Products.
     *
     * @param array $entity Snippet Data
     * @return array
     */
    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
        global $post; 
    
        // Replace 'brand-cf' with the actual custom field name where you store the brand name
        $brand_name = get_post_meta( $post->ID, 'brand-cf', true );  // Retrieve brand name from custom field
    
        if ( ! empty( $brand_name ) ) {
            $entity['brand']['@type'] = 'Brand';
            $entity['brand']['name'] = $brand_name;
        }
    
        return $entity;
    });

    We hope this helps you resolve the issue. Don’t hesitate to contact us again with any other questions or concerns regarding Rank Math. We are always happy to help.

    Thank you for choosing Rank Math!

    Ayan
    Rank Math free

    Hi thanks for the above code.

    However, even after adding the code to the site, Google Merchant center is not detecting the allotted brand.

    Any help/advice please?

    Hello,

    To help you investigate this issue, we might need to take a closer look at your website and settings. Please follow these steps:

    • Edit the first post on this ticket and include your WordPress logins in the Sensitive Data section. This is a secure section that only our support staff can access.
      Sensitive Data Section
    • Make sure you take a complete backup of your website before sharing the information with us.
    • If you prefer, you can use this plugin to generate a temporary login URL to your website and share that with us instead: https://wordpress.org/plugins/temporary-login-without-password/
    • You can also use this plugin to monitor what changes our staff might make on your website (if any): https://wordpress.org/plugins/wp-security-audit-log/

    We appreciate your cooperation and patience. Thank you for choosing Rank Math.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

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

The ticket ‘Use Brand Names from another column’ is closed to new replies.