adgroup_criterion_service = client.GetService(
'AdGroupCriterionService', version='v201809')
selector = {
'fields':['ParentCriterionId'],
'predicates':[
{
'field':'AdGroupId',
'operator': 'EQUALS',
'values': adgroup_id
}
]
}
page = adgroup_criterion_service.get(selector)
parent = page['entries'][0]['criterion']
helper = ProductPartitionHelper(adgroup_id)
#root = helper.CreateSubdivision()
for pla in PLAList:
new_product = {
'xsi_type' : 'ProductOfferId',
'value' : ''
}
new_product['value'] = pla
#helper.CreateUnit(self,parent=parent, new_product, 200000)
helper.CreateUnit(parent=parent,value=new_product,bid_amount=20000)
other_products = {
'xsi_type': 'ProductOfferId',
}
#helper.CreateUnit(
# root, other_products)
# Make the mutate request
result = adgroup_criterion_service.mutate(helper.GetOperations())---You need to use the adgroup_criterion_service get on the parentcriterionID to get the tree, then mutate the tree.I iterate through my list of Ids to add "for pla in PLAList" -- note you cannot add more than 5000~ in a single mutate -- and there are limits to how large the tree can be - if you exceed something like 12-13k it will give an exception.--Hope this helps you out - it took me a while to understand how to manipulate these. The example only works for creating the tree, so it errors if you try to do it where one already exists.
Hi everyone,
Thank you Kevin for the additional information. For bulk updates on your ProductPartitions, you can use the BatchJobService and you can refer to this section for the considerations in order to successfully execute your requests.
Best regards,
Peter
Google Ads API Team