• Hi!

    Are there any php hooks & filters to programatically control the product title format in the feed?

Viewing 1 replies (of 1 total)
  • Plugin Support Tanjir Al Mamun

    (@tanjiralmamun)

    Hi @marianssen,

    Yes, the main hook for this is adt_get_product_data. It fires after all product data (including variation attribute appends) has been collected, giving you access to modify $product_data['title'] before it’s written to the feed.

      add_filter( 'adt_get_product_data', function( $product_data, $feed, $product
    ) {
    // Example: append the SKU to every product title
    if ( ! empty( $product_data['title'] ) && ! empty( $product_data['sku'] )
    ) {
    $product_data['title'] = $product_data['title'] . ' [' .
    $product_data['sku'] . ']';
    }
    return $product_data;
    }, 10, 3 );

    The $feed parameter gives you access to the feed configuration (e.g., $feed->id, $feed->title) if you want to apply the change only to specific feeds. The $product parameter is the standard WC_Product object.

    For XML feeds specifically, adt_product_feed_xml_attribute_value lets you target a single attribute value at write-time:

      add_filter( 'adt_get_product_data', function( $product_data, $feed, $product ) {
    // Example: append the SKU to every product title
    if ( ! empty( $product_data['title'] ) && ! empty( $product_data['sku'] ) ) {
    $product_data['title'] = $product_data['title'] . ' [' . $product_data['sku'] . ']';
    }
    return $product_data;
    }, 10, 3 );

    Hope that covers what you need. Let us know if you run into anything unexpected.

    Thanks!

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.