examples/AdWords/v201809/ShoppingCampaigns/AddSmartShoppingAd.php
private static function createSmartShoppingAdGroup(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        $campaignId
    ) {
        $adGroupService =
            $adWordsServices->get($session, AdGroupService::class);

        // Create an ad group.
        $adGroup = new AdGroup();
        $adGroup->setCampaignId($campaignId);
        $adGroup->setName('Smart Shopping ad group #' . uniqid());

        // Set the ad group type to SHOPPING_GOAL_OPTIMIZED_ADS.
        $adGroup->setAdGroupType(AdGroupType::SHOPPING_GOAL_OPTIMIZED_ADS);

        // Create operation.
        $adGroupOperation = new AdGroupOperation();
        $adGroupOperation->setOperand($adGroup);
        $adGroupOperation->setOperator(Operator::ADD);

        // Create the ad group on the server and print out some information.
        $addedAdGroup = $adGroupService->mutate([$adGroupOperation])
            ->getValue()[0];
        printf(
            "Smart Shopping ad group with name '%s' and ID %d was added.%s",
            $addedAdGroup->getName(),
            $addedAdGroup->getId(),
            PHP_EOL
        );

        return $addedAdGroup->getId();
    }
private static function createSmartShoppingAdGroup(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        $campaignId
    ) {
        $adGroupService =
            $adWordsServices->get($session, AdGroupService::class);

        // Create an ad group.
        $adGroup = new AdGroup();
        $adGroup->setCampaignId($campaignId);
        $adGroup->setName('Smart Shopping ad group #' . uniqid());

        // Set the ad group type to SHOPPING_GOAL_OPTIMIZED_ADS.
        $adGroup->setAdGroupType(AdGroupType::SHOPPING_GOAL_OPTIMIZED_ADS);

        // Create operation.
        $adGroupOperation = new AdGroupOperation();
        $adGroupOperation->setOperand($adGroup);
        $adGroupOperation->setOperator(Operator::ADD);

        // Create the ad group on the server and print out some information.
        $addedAdGroup = $adGroupService->mutate([$adGroupOperation])
            ->getValue()[0];
        printf(
            "Smart Shopping ad group with name '%s' and ID %d was added.%s",
            $addedAdGroup->getName(),
            $addedAdGroup->getId(),
            PHP_EOL
        );

        return $addedAdGroup->getId();
    }
private static function createSmartShoppingAdGroup ( AdWordsServices $ adWordsServices , AdWordsSession $ session , $ campaignId ) { $ adGroupService = $ adWordsServices -> get ( $ session , AdGroupService :: class ) ; // Create an ad group. $ adGroup = new AdGroup ( ) ; $ adGroup -> setCampaignId ( $ campaignId ) ; $ adGroup -> setName ( 'Smart Shopping ad group #' . uniqid ( ) ) ; // Set the ad group type to SHOPPING_GOAL_OPTIMIZED_ADS. $ adGroup -> setAdGroupType ( AdGroupType :: SHOPPING_GOAL_OPTIMIZED_ADS ) ; // Create operation. $ adGroupOperation = new AdGroupOperation ( ) ; $ adGroupOperation -> setOperand ( $ adGroup ) ; $ adGroupOperation -> setOperator ( Operator :: ADD ) ; // Create the ad group on the server and print out some information. $ addedAdGroup = $ adGroupService -> mutate ( [ $ adGroupOperation ] ) -> getValue ( ) [ 0 ] ; printf ( "Smart Shopping ad group with name '%s' and ID %d was added.%s" , $ addedAdGroup -> getName ( ) , $ addedAdGroup -> getId ( ) , PHP_EOL ) ; return $ addedAdGroup -> getId ( ) ; }
Creates a Smart Shopping ad group by setting the ad group type to
SHOPPING_GOAL_OPTIMIZED_ADS.

@param AdWordsServices $adWordsServices the AdWords services
@param AdWordsSession $session the AdWords session
@param int $campaignId the campaign ID
@return int the ad group ID
Creates a Smart Shopping ad group by setting the ad group type to SHOPPING_GOAL_OPTIMIZED_ADS .