examples/AdWords/v201809/ShoppingCampaigns/AddSmartShoppingAd.php
private static function createSmartShoppingAd(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        $adGroupId
    ) {
        $adGroupAdService =
            $adWordsServices->get($session, AdGroupAdService::class);

        // Create a Smart Shopping ad (Goal-optimized Shopping ad).
        $smartShoppingAd = new GoalOptimizedShoppingAd();

        // Create an ad group ad.
        $adGroupAd = new AdGroupAd();
        $adGroupAd->setAdGroupId($adGroupId);
        $adGroupAd->setAd($smartShoppingAd);

        // Create an ad group ad operation and add it to the operations list.
        $operation = new AdGroupAdOperation();
        $operation->setOperand($adGroupAd);
        $operation->setOperator(Operator::ADD);

        // Create the ad group ad on the server and print out some information.
        $addedAdGroupAd = $adGroupAdService->mutate([$operation])
            ->getValue()[0];
        printf(
            "Smart Shopping ad with ID %d was added.%s",
            $addedAdGroupAd->getAd()->getId(),
            PHP_EOL
        );
    }
private static function createSmartShoppingAd(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        $adGroupId
    ) {
        $adGroupAdService =
            $adWordsServices->get($session, AdGroupAdService::class);

        // Create a Smart Shopping ad (Goal-optimized Shopping ad).
        $smartShoppingAd = new GoalOptimizedShoppingAd();

        // Create an ad group ad.
        $adGroupAd = new AdGroupAd();
        $adGroupAd->setAdGroupId($adGroupId);
        $adGroupAd->setAd($smartShoppingAd);

        // Create an ad group ad operation and add it to the operations list.
        $operation = new AdGroupAdOperation();
        $operation->setOperand($adGroupAd);
        $operation->setOperator(Operator::ADD);

        // Create the ad group ad on the server and print out some information.
        $addedAdGroupAd = $adGroupAdService->mutate([$operation])
            ->getValue()[0];
        printf(
            "Smart Shopping ad with ID %d was added.%s",
            $addedAdGroupAd->getAd()->getId(),
            PHP_EOL
        );
    }
private static function createSmartShoppingAd ( AdWordsServices $ adWordsServices , AdWordsSession $ session , $ adGroupId ) { $ adGroupAdService = $ adWordsServices -> get ( $ session , AdGroupAdService :: class ) ; // Create a Smart Shopping ad (Goal-optimized Shopping ad). $ smartShoppingAd = new GoalOptimizedShoppingAd ( ) ; // Create an ad group ad. $ adGroupAd = new AdGroupAd ( ) ; $ adGroupAd -> setAdGroupId ( $ adGroupId ) ; $ adGroupAd -> setAd ( $ smartShoppingAd ) ; // Create an ad group ad operation and add it to the operations list. $ operation = new AdGroupAdOperation ( ) ; $ operation -> setOperand ( $ adGroupAd ) ; $ operation -> setOperator ( Operator :: ADD ) ; // Create the ad group ad on the server and print out some information. $ addedAdGroupAd = $ adGroupAdService -> mutate ( [ $ operation ] ) -> getValue ( ) [ 0 ] ; printf ( "Smart Shopping ad with ID %d was added.%s" , $ addedAdGroupAd -> getAd ( ) -> getId ( ) , PHP_EOL ) ; }
Creates a Smart Shopping ad.

@param AdWordsServices $adWordsServices the AdWords services
@param AdWordsSession $session the AdWords session
@param int $adGroupId the ad group ID
Creates a Smart Shopping ad .