I am following the example PHP script for adding a group partition found 
here: 
https://github.com/googleads/googleads-php-lib/blob/master/examples/AdWords/v201402/ShoppingCampaigns/AddProductPartitionTree.php

The adGroup is created in AdWords and only contains the default Partition 
which is of a type UNIT.  When I try the following code. I get this error: 

attempting change failed: 
[AdGroupCriterionError.PRODUCT_PARTITION_ALREADY_EXISTS @ 
operations[0].operand.criterion, 
AdGroupCriterionError.PRODUCT_PARTITION_DOES_NOT_EXIST @ 
operations[1].operand.criterion.parentCriterionId; 
trigger:'TempCriterionId{id=1}']

PHP Code: 

$operations = [];

// Create Root
$root = new ProductPartition('SUBDIVISION');
$root->id = -1;

$rootCriterion = new BiddableAdGroupCriterion();
$rootCriterion ->adGroupId = $adGroupId;
$rootCriterion ->criterion = $root;

$rootOperation = new AdGroupCriterionOperation();
$rootOperation->operand = $rootCriterion ;
$rootOperation->operator = 'ADD';
$operations[] = $rootOperation;

// Create bid for product
$value = new ProductOfferId();
$value->value = 'MANCHUCK';

$unit = new ProductPartition('UNIT');
$unit->parentCriterionId = $root->id;
$unit->caseValue = $value;

$biddingStrategyConfiguration = new \BiddingStrategyConfiguration();
$biddingStrategyConfiguration->bids = [];
$cpcBid = new \CpcBid();
$cpcBid->bid = new \Money(20000);
$biddingStrategyConfiguration->bids[] = $cpcBid;

$criterion = new \BiddableAdGroupCriterion();
$criterion->adGroupId = $adGroupId;
$criterion->criterion = $unit;
$criterion->biddingStrategyConfiguration = $biddingStrategyConfiguration;

$operation = new \AdGroupCriterionOperation();
$operation->operand = $criterion;
$operation->operator = 'ADD';
$operations[] = $operation;

// Send the ops to be mutated
try {
    $service->mutate($operations);
} catch (\Exception $googleException) {
    echo sprintf('attempting change failed: %s', 
$googleException->getMessage());
    die(2);
}


echo "Done";


If I use the Admin panel to create the unit partition as I want, I see that 
3 partitions are created

The default partition is updated to be of type SUBDIVISION
The 2nd partition is the one that contains the item I wanted 
The 3rd partition is the fallback for everything else.  

I tried to SET the root partition as a SUBDIVISION then add the other two 
which failed with the following error: 
attempting change failed: 
[AdGroupCriterionError.PRODUCT_PARTITION_UNIT_CANNOT_HAVE_CHILDREN @ 
operations; trigger:'ProductPartition{id=CriterionId{id=*********}, 
bidSimulatorStatus=null, partitionType=UNIT, parentCriterionId=null, 
caseValue=null, decisionPath=[]}']

I then tried to just add the one UNIT partition alone and got an error 
stating I'm missing the parentCriterionId:
attempting change failed: [RequiredError.REQUIRED @ 
operations[0].operand.criterion.parentCriterionId]

So I then tried doing the -1 for that Id and got 

attempting change failed: 
[AdGroupCriterionError.PRODUCT_PARTITION_DOES_NOT_EXIST @ 
operations[0].operand.criterion.parentCriterionId; 
trigger:'TempCriterionId{id=1}']

I have not tried to remove the default partition and starting with a clean 
slate because I do not see that happening through the UI.  I have been all 
over the docs and the code I pasted above is all I found about the subject. 
 Is there something I am missing in the docs?  Is there a step that might 
not be documented?  Could there be something with the 
account/campaign/adGroup that I need to change that I missed?  Any insight 
would be helpful.

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords 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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to