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

        // Creates an ad group criterion for 'All products'.
        $productPartition = new ProductPartition();
        $productPartition->setPartitionType(ProductPartitionType::UNIT);

        // Creates a biddable ad group criterion.
        $criterion = new BiddableAdGroupCriterion();
        $criterion->setAdGroupId($adGroupId);
        $criterion->setCriterion($productPartition);

        // Creates an ad group criterion operation.
        $operation = new AdGroupCriterionOperation();
        $operation->setOperand($criterion);
        $operation->setOperator(Operator::ADD);

        $addedAdGroupCriterion = $adGroupCriterionService->mutate([$operation])
            ->getValue()[0];
        printf(
            "Ad group criterion with ID %d in ad group with ID %d"
            . " was added.%s",
            $addedAdGroupCriterion->getCriterion()->getId(),
            $addedAdGroupCriterion->getAdGroupId(),
            PHP_EOL
        );
    }
private static function createDefaultPartition(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        $adGroupId
    ) {
        $adGroupCriterionService =
            $adWordsServices->get($session, AdGroupCriterionService::class);

        // Creates an ad group criterion for 'All products'.
        $productPartition = new ProductPartition();
        $productPartition->setPartitionType(ProductPartitionType::UNIT);

        // Creates a biddable ad group criterion.
        $criterion = new BiddableAdGroupCriterion();
        $criterion->setAdGroupId($adGroupId);
        $criterion->setCriterion($productPartition);

        // Creates an ad group criterion operation.
        $operation = new AdGroupCriterionOperation();
        $operation->setOperand($criterion);
        $operation->setOperator(Operator::ADD);

        $addedAdGroupCriterion = $adGroupCriterionService->mutate([$operation])
            ->getValue()[0];
        printf(
            "Ad group criterion with ID %d in ad group with ID %d"
            . " was added.%s",
            $addedAdGroupCriterion->getCriterion()->getId(),
            $addedAdGroupCriterion->getAdGroupId(),
            PHP_EOL
        );
    }
private static function createDefaultPartition ( AdWordsServices $ adWordsServices , AdWordsSession $ session , $ adGroupId ) { $ adGroupCriterionService = $ adWordsServices -> get ( $ session , AdGroupCriterionService :: class ) ; // Creates an ad group criterion for 'All products'. $ productPartition = new ProductPartition ( ) ; $ productPartition -> setPartitionType ( ProductPartitionType :: UNIT ) ; // Creates a biddable ad group criterion. $ criterion = new BiddableAdGroupCriterion ( ) ; $ criterion -> setAdGroupId ( $ adGroupId ) ; $ criterion -> setCriterion ( $ productPartition ) ; // Creates an ad group criterion operation. $ operation = new AdGroupCriterionOperation ( ) ; $ operation -> setOperand ( $ criterion ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ addedAdGroupCriterion = $ adGroupCriterionService -> mutate ( [ $ operation ] ) -> getValue ( ) [ 0 ] ; printf ( "Ad group criterion with ID %d in ad group with ID %d" . " was added.%s" , $ addedAdGroupCriterion -> getCriterion ( ) -> getId ( ) , $ addedAdGroupCriterion -> getAdGroupId ( ) , PHP_EOL ) ; }
Creates a default product partition as an ad group criterion.

@param AdWordsServices $adWordsServices the AdWords services
@param AdWordsSession $session the AdWords session
@param int $adGroupId the ad group ID
Creates a default product partition as an ad group criterion .