Modifying existing Product Partition trees

71 views
Skip to first unread message

CDG

unread,
Jun 9, 2019, 11:25:27 PM6/9/19
to AdWords API and Google Ads API Forum
Hello there
I am using the python example to create Product Partition trees

Now
I want to update the tree, but I always get the error.

--
'trigger': None,
'errorString': 'AdGroupCriterionError.PRODUCT_PARTITION_ALREADY_EXISTS',
'ApiError.Type': 'AdGroupCriterionError',
'reason': 'PRODUCT_PARTITION_ALREADY_EXISTS'
---

help me to solve the problem, thanks.

Google Ads API Forum Advisor Prod

unread,
Jun 10, 2019, 5:04:13 AM6/10/19
to adwor...@googlegroups.com
Hi,

Based on the error, your request for creating a subdivision is failing because there is already an existing product partition. I would recommend that you first use the AdGroupCriterion.GetAdGroupCriterion method to see whether the partition already exists before trying to create one.

You may send to me your JSON logs, using the Reply privately to author option, should the issue persist.

Thanks and regards,
Peter
Google Ads API Team

ref:_00D1U1174p._5001UBmQUL:ref

Kevin Weitzner

unread,
Jun 12, 2019, 12:45:33 PM6/12/19
to AdWords API and Google Ads API Forum
Do you still need help with this?  Here is some example in code from one of my python scripts

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.


CDG

unread,
Jun 15, 2019, 10:19:46 PM6/15/19
to AdWords API and Google Ads API Forum
hi Kevin,

Thank you for your answer.
,
I am currently able to create tree content and add it to the Google advertising product group through examples and your responses.

I want to ask is, is there any way to modify the created tree?

Kevin Weitzner於 2019年6月13日星期四 UTC+8上午12時45分33秒寫道:

Google Ads API Forum Advisor Prod

unread,
Jun 17, 2019, 4:35:24 AM6/17/19
to adwor...@googlegroups.com
Hi,

Could you confirm if you are indeed using the old AdWords API? If yes, you will need to specify the ProductPartition's Id in the your AdGroupCriterionService.mutate() SET request and include the fields you wish to modify. In the event that you wish to ADD or REMOVE a node to a subdivision, you will then need to specify the parentCriterionId.

Kevin Weitzner

unread,
Jun 17, 2019, 10:11:05 AM6/17/19
to AdWords API and Google Ads API Forum
You can - but due to the nature of how product trees exist, you have to ensure every mutate results in a valid resulting tree, else the call will fail.

You can use a similar method to 'remove' product groups.

Note - due to a size limit, you may not be able to perform too many changes at a time else the calls will fail.  When I remove product groups, I submit mutate requests with each pass - unlike with the creation, where I submit many in a single mutate.
==

You can do bid arguments with the same style- using "SET" as Peter stated.

Google Ads API Forum Advisor Prod

unread,
Jun 17, 2019, 11:08:02 PM6/17/19
to adwor...@googlegroups.com

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



ref:_00D1U1174p._5001UBmQUL:ref
Reply all
Reply to author
Forward
0 new messages