// Creates an extension feed item using the specified feed item ID and sitelink text.
$extensionFeedItem = new ExtensionFeedItem([
'resource_name' => ResourceNames::forExtensionFeedItem($customerId, $feedItemId),
'sitelink_feed_item' => new SitelinkFeedItem(['link_text' => $sitelinkText])
]);
// Constructs an operation that will update the extension feed item, using the FieldMasks
// utility to derive the update mask. This mask tells the Google Ads API which attributes of
// the extension feed item you want to change.
$extensionFeedItemOperation = new ExtensionFeedItemOperation();
$extensionFeedItemOperation->setUpdate($extensionFeedItem);
$extensionFeedItemOperation->setUpdateMask(FieldMasks::allSetFieldsOf($extensionFeedItem));
// Issues a mutate request to update the extension feed item.
$extensionFeedItemServiceClient = $googleAdsClient->getExtensionFeedItemServiceClient();
$response = $extensionFeedItemServiceClient->mutateExtensionFeedItems(
$customerId,
[$extensionFeedItemOperation]
);
// Prints the resource name of the updated extension feed item.
/** @var ExtensionFeedItem $updatedExtensionFeedItem */
$updatedExtensionFeedItem = $response->getResults()[0];
printf(
"Updated extension feed item with resource name: '%s'.%s",
$updatedExtensionFeedItem->getResourceName(),
PHP_EOL
);