Hello Bala,

Please find the attached code snippet which creates the Product partition
tree based on ProductBrand. Could you please give this a try and let us
know if you have any questions?

Thanks,
Bharani, Google Ads API Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    https://ads-developers.googleblog.com/search/label/google_ads_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- You received this message because you are subscribed to the Google Groups "AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/1a0sc2000000000106r6da000lc2muw6kmj4cpm68o30c1g68r3cchp%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
<?php
/**
 * Copyright 2017 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace Google\AdsApi\Examples\AdWords\v201809\ShoppingCampaigns;

require __DIR__ . '/../../../../vendor/autoload.php';

use Google\AdsApi\AdWords\AdWordsServices;
use Google\AdsApi\AdWords\AdWordsSession;
use Google\AdsApi\AdWords\AdWordsSessionBuilder;
use Google\AdsApi\AdWords\Shopping\v201809\ProductPartitions;
use Google\AdsApi\AdWords\v201809\cm\AdGroupCriterionService;
use Google\AdsApi\AdWords\v201809\cm\ProductBiddingCategory;
use Google\AdsApi\AdWords\v201809\cm\ProductBrand;
use Google\AdsApi\AdWords\v201809\cm\ProductPartition;
use Google\AdsApi\AdWords\v201809\cm\ProductPartitionType;
use Google\AdsApi\AdWords\v201809\cm\ProductCanonicalCondition;
use Google\AdsApi\AdWords\v201809\cm\ProductCanonicalConditionCondition;
use Google\AdsApi\AdWords\v201809\cm\ProductDimensionType;
use Google\AdsApi\Common\OAuth2TokenBuilder;

/**
 * This example creates a product partition tree.
 */
class AddProductPartitionTree
{

	const AD_GROUP_ID = '68397208294';

    public static function runExample(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        $adGroupId
    ) {
        // The most trivial partition tree has only a unit node as the root:
        //   $productPartitions->createBiddableUnit(null, null, 100000);

		$operations = [];
		
		$root = ProductPartitions::createSubdivision();
		$criterion = ProductPartitions::asBiddableAdGroupCriterion($adGroupId, $root);
		$operation = ProductPartitions::createAddOperation($criterion);
		$operations[] = $operation;
		
		$coolBrand = new ProductBrand();
		$coolBrand->setValue('CoolBrand');
		$coolBrandUnit = ProductPartitions::createUnit($root, $coolBrand);
		$criterion = ProductPartitions::asBiddableAdGroupCriterion($adGroupId,$coolBrandUnit,200000);
		$operation = ProductPartitions::createAddOperation($criterion);
		$operations[] = $operation;
		
		
		$cheapBrand = new ProductBrand();
		$cheapBrand->setValue('CheapBrand');
		$cheapBrandUnit = ProductPartitions::createUnit($root, $cheapBrand);
		$criterion = ProductPartitions::asBiddableAdGroupCriterion(
																   $adGroupId,
																   $cheapBrandUnit,
																   100000
																   );
		$operation = ProductPartitions::createAddOperation($criterion);
		$operations[] = $operation;
		
		$otherCondition = ProductPartitions::createUnit($root, new ProductBrand());
		$criterion = ProductPartitions::asBiddableAdGroupCriterion($adGroupId,$otherCondition, 100000);
		$operation = ProductPartitions::createAddOperation($criterion);
		$operations[] = $operation;
		
		$adGroupCriterionService = $adWordsServices->get($session, AdGroupCriterionService::class);
		$result = $adGroupCriterionService->mutate($operations);
		print_r($result);

    }

    public static function main()
    {
        // Generate a refreshable OAuth2 credential for authentication.
        $oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build();

        // Construct an API session configured from a properties file and the
        // OAuth2 credentials above.
        $session = (new AdWordsSessionBuilder())->fromFile()->withOAuth2Credential($oAuth2Credential)->build();
        self::runExample(
            new AdWordsServices(),
            $session,
            intval(self::AD_GROUP_ID)
        );
    }
}

AddProductPartitionTree::main();
  • PRODUCT... murugan
    • RE... googleadsapi-forumadvisor via AdWords API and Google Ads API Forum
      • ... murugan
      • ... murugan
        • ... googleadsapi-forumadvisor via AdWords API and Google Ads API Forum
          • ... Bala Murugan
            • ... googleadsapi-forumadvisor via AdWords API and Google Ads API Forum
              • ... Bala Murugan
    • RE... Google Ads API Forum Advisor Prod

Reply via email to