examples/AdWords/v201809/AdvancedOperations/AddAdCustomizer.php
private static function restrictFeedItemToAdGroup(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        FeedItem $feedItem,
        $adGroupId
    ) {
        $feedItemTargetService =
            $adWordsServices->get($session, FeedItemTargetService::class);

        // Create a feed item ad group target.
        $adGroupTarget = new FeedItemAdGroupTarget();
        $adGroupTarget->setFeedId($feedItem->getFeedId());
        $adGroupTarget->setFeedItemId($feedItem->getFeedItemId());
        $adGroupTarget->setAdGroupId($adGroupId);

        // Create a feed item target operation.
        $operation = new FeedItemTargetOperation();
        $operation->setOperator(Operator::ADD);
        $operation->setOperand($adGroupTarget);

        // Add a feed item target on the server and print out some information.
        $result = $feedItemTargetService->mutate([$operation]);
        $addedAdGroupTarget = $result->getValue()[0];
        sprintf(
            'Feed item target for feed ID %s and feed item ID %s '
            . 'was created to restrict serving to ad group ID %s.%s',
            $addedAdGroupTarget->getFeedId(),
            $addedAdGroupTarget->getFeedItemId(),
            $addedAdGroupTarget->getAdGroupId(),
            PHP_EOL
        );
    }
private static function restrictFeedItemToAdGroup(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        FeedItem $feedItem,
        $adGroupId
    ) {
        $feedItemTargetService =
            $adWordsServices->get($session, FeedItemTargetService::class);

        // Create a feed item ad group target.
        $adGroupTarget = new FeedItemAdGroupTarget();
        $adGroupTarget->setFeedId($feedItem->getFeedId());
        $adGroupTarget->setFeedItemId($feedItem->getFeedItemId());
        $adGroupTarget->setAdGroupId($adGroupId);

        // Create a feed item target operation.
        $operation = new FeedItemTargetOperation();
        $operation->setOperator(Operator::ADD);
        $operation->setOperand($adGroupTarget);

        // Add a feed item target on the server and print out some information.
        $result = $feedItemTargetService->mutate([$operation]);
        $addedAdGroupTarget = $result->getValue()[0];
        sprintf(
            'Feed item target for feed ID %s and feed item ID %s '
            . 'was created to restrict serving to ad group ID %s.%s',
            $addedAdGroupTarget->getFeedId(),
            $addedAdGroupTarget->getFeedItemId(),
            $addedAdGroupTarget->getAdGroupId(),
            PHP_EOL
        );
    }
private static function restrictFeedItemToAdGroup ( AdWordsServices $ adWordsServices , AdWordsSession $ session , FeedItem $ feedItem , $ adGroupId ) { $ feedItemTargetService = $ adWordsServices -> get ( $ session , FeedItemTargetService :: class ) ; // Create a feed item ad group target. $ adGroupTarget = new FeedItemAdGroupTarget ( ) ; $ adGroupTarget -> setFeedId ( $ feedItem -> getFeedId ( ) ) ; $ adGroupTarget -> setFeedItemId ( $ feedItem -> getFeedItemId ( ) ) ; $ adGroupTarget -> setAdGroupId ( $ adGroupId ) ; // Create a feed item target operation. $ operation = new FeedItemTargetOperation ( ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ operation -> setOperand ( $ adGroupTarget ) ; // Add a feed item target on the server and print out some information. $ result = $ feedItemTargetService -> mutate ( [ $ operation ] ) ; $ addedAdGroupTarget = $ result -> getValue ( ) [ 0 ] ; sprintf ( 'Feed item target for feed ID %s and feed item ID %s ' . 'was created to restrict serving to ad group ID %s.%s' , $ addedAdGroupTarget -> getFeedId ( ) , $ addedAdGroupTarget -> getFeedItemId ( ) , $ addedAdGroupTarget -> getAdGroupId ( ) , PHP_EOL ) ; }
Restricts the feed item to an ad group.

@param AdWordsServices $adWordsServices the AdWords services
@param AdWordsSession $session the AdWords session
@param FeedItem $feedItem the feed item to restrict
@param int $adGroupId the ad group ID to which the feed item will be
restricted
Restricts the feed item to an ad group .