Chuck, We have a related forum thread <https://groups.google.com/forum/#!msg/adwords-api/P6DYn6N3XTU/URoOTS5xGIUJ> that had similar issues and examples. Also for your reference, we have a set of slides <http://www.slideshare.net/marcwan/02-shopping> that you may find helpful as well.
The partition type <https://developers.google.com/adwords/api/docs/reference/v201402/AdGroupCriterionService.ProductPartition#partitionType> can only be set when using the ADD operation, hence you will need to remove the root node and re-adding it with the SUBDIVISON type. Lastly, when adding children nodes, you can use the temporary ID *if* you are also re-adding the parent node with that ID in the same mutate request. Otherwise, you would need to set it to a valid parent ID that may already exist. Thanks! Ray On Friday, June 20, 2014 11:33:47 AM UTC-4, Chuck Reeves wrote: > > 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 [email protected] To unsubscribe from this group, send email to [email protected] 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
