examples/AdWords/v201809/ShoppingCampaigns/AddShoppingCampaignForShowcaseAds.php
private static function createProductPartitions(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        $adGroupId
    ) {
        $operations = [];

        $root = ProductPartitions::createSubdivision();
        $criterion = ProductPartitions::asBiddableAdGroupCriterion($adGroupId, $root);
        $operation = ProductPartitions::createAddOperation($criterion);
        $operations[] = $operation;

        $newCondition = new ProductCanonicalCondition();
        $newCondition->setCondition(ProductCanonicalConditionCondition::NEW_VALUE);
        $newConditionUnit = ProductPartitions::createUnit($root, $newCondition);
        $criterion = ProductPartitions::asBiddableAdGroupCriterion(
            $adGroupId,
            $newConditionUnit
        );
        $operation = ProductPartitions::createAddOperation($criterion);
        $operations[] = $operation;

        $usedCondition = new ProductCanonicalCondition();
        $usedCondition->setCondition(ProductCanonicalConditionCondition::USED);
        $usedConditionUnit = ProductPartitions::createUnit($root, $usedCondition);
        $criterion = ProductPartitions::asBiddableAdGroupCriterion(
            $adGroupId,
            $usedConditionUnit
        );
        $operation = ProductPartitions::createAddOperation($criterion);
        $operations[] = $operation;

        // Exclude everything else.
        $excludedUnit = ProductPartitions::createUnit($root, new ProductCanonicalCondition());
        $criterion = ProductPartitions::asNegativeAdGroupCriterion(
            $adGroupId,
            $excludedUnit
        );
        $operation = ProductPartitions::createAddOperation($criterion);
        $operations[] = $operation;

        $adGroupCriterionService = $adWordsServices->get($session, AdGroupCriterionService::class);

        // Creates ad group criteria on the server.
        $adGroupCriterionService->mutate($operations);
    }
private static function createProductPartitions(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        $adGroupId
    ) {
        $operations = [];

        $root = ProductPartitions::createSubdivision();
        $criterion = ProductPartitions::asBiddableAdGroupCriterion($adGroupId, $root);
        $operation = ProductPartitions::createAddOperation($criterion);
        $operations[] = $operation;

        $newCondition = new ProductCanonicalCondition();
        $newCondition->setCondition(ProductCanonicalConditionCondition::NEW_VALUE);
        $newConditionUnit = ProductPartitions::createUnit($root, $newCondition);
        $criterion = ProductPartitions::asBiddableAdGroupCriterion(
            $adGroupId,
            $newConditionUnit
        );
        $operation = ProductPartitions::createAddOperation($criterion);
        $operations[] = $operation;

        $usedCondition = new ProductCanonicalCondition();
        $usedCondition->setCondition(ProductCanonicalConditionCondition::USED);
        $usedConditionUnit = ProductPartitions::createUnit($root, $usedCondition);
        $criterion = ProductPartitions::asBiddableAdGroupCriterion(
            $adGroupId,
            $usedConditionUnit
        );
        $operation = ProductPartitions::createAddOperation($criterion);
        $operations[] = $operation;

        // Exclude everything else.
        $excludedUnit = ProductPartitions::createUnit($root, new ProductCanonicalCondition());
        $criterion = ProductPartitions::asNegativeAdGroupCriterion(
            $adGroupId,
            $excludedUnit
        );
        $operation = ProductPartitions::createAddOperation($criterion);
        $operations[] = $operation;

        $adGroupCriterionService = $adWordsServices->get($session, AdGroupCriterionService::class);

        // Creates ad group criteria on the server.
        $adGroupCriterionService->mutate($operations);
    }
private static function createProductPartitions ( AdWordsServices $ adWordsServices , AdWordsSession $ session , $ adGroupId ) { $ operations = [ ] ; $ root = ProductPartitions :: createSubdivision ( ) ; $ criterion = ProductPartitions :: asBiddableAdGroupCriterion ( $ adGroupId , $ root ) ; $ operation = ProductPartitions :: createAddOperation ( $ criterion ) ; $ operations [ ] = $ operation ; $ newCondition = new ProductCanonicalCondition ( ) ; $ newCondition -> setCondition ( ProductCanonicalConditionCondition :: NEW_VALUE ) ; $ newConditionUnit = ProductPartitions :: createUnit ( $ root , $ newCondition ) ; $ criterion = ProductPartitions :: asBiddableAdGroupCriterion ( $ adGroupId , $ newConditionUnit ) ; $ operation = ProductPartitions :: createAddOperation ( $ criterion ) ; $ operations [ ] = $ operation ; $ usedCondition = new ProductCanonicalCondition ( ) ; $ usedCondition -> setCondition ( ProductCanonicalConditionCondition :: USED ) ; $ usedConditionUnit = ProductPartitions :: createUnit ( $ root , $ usedCondition ) ; $ criterion = ProductPartitions :: asBiddableAdGroupCriterion ( $ adGroupId , $ usedConditionUnit ) ; $ operation = ProductPartitions :: createAddOperation ( $ criterion ) ; $ operations [ ] = $ operation ; // Exclude everything else. $ excludedUnit = ProductPartitions :: createUnit ( $ root , new ProductCanonicalCondition ( ) ) ; $ criterion = ProductPartitions :: asNegativeAdGroupCriterion ( $ adGroupId , $ excludedUnit ) ; $ operation = ProductPartitions :: createAddOperation ( $ criterion ) ; $ operations [ ] = $ operation ; $ adGroupCriterionService = $ adWordsServices -> get ( $ session , AdGroupCriterionService :: class ) ; // Creates ad group criteria on the server. $ adGroupCriterionService -> mutate ( $ operations ) ; }
Creates the product partition tree for the ad group.
Creates the product partition tree for the ad group .