Add an OfferID to an existing partition

40 views
Skip to first unread message

TommyTek

unread,
May 8, 2019, 4:59:38 PM5/8/19
to AdWords API and Google Ads API Forum
Hello,
  I've created a product partition with 2 offers this way (it works):

// create subdivision    
    $operations = [];
    $root = ProductPartitions::createSubdivision();
    $criterion = ProductPartitions::asBiddableAdGroupCriterion($adGroup->getId(), $root);
    $operation = ProductPartitions::createAddOperation($criterion);
    $operations[] = $operation;
    
    $ean = new ProductOfferId();
    $ean->setValue('0000000001');
    $eanUnit = ProductPartitions::createUnit($root, $ean);
    $criterion = ProductPartitions::asBiddableAdGroupCriterion(
        $adGroup->getId(),
        $eanUnit,
        10*10000
    );
    $operation = ProductPartitions::createAddOperation($criterion);
    $operations[] = $operation;
   
    $ean = new ProductOfferId();
    $ean->setValue('0000000002');
    $eanUnit = ProductPartitions::createUnit($root, $ean);
    $criterion = ProductPartitions::asBiddableAdGroupCriterion(
        $adGroup->getId(),
        $eanUnit,
        11*10000
    );
    $operation = ProductPartitions::createAddOperation($criterion);
    $operations[] = $operation;

    
    // Other
    $ean = new ProductOfferId();
    $eanUnit = ProductPartitions::createUnit($root, $ean);
    $criterion = ProductPartitions::asNegativeAdGroupCriterion(
        $adGroup->getId(),
        $eanUnit
    );
    $operation = ProductPartitions::createAddOperation($criterion);
    $operations[] = $operation;
   
    
    $adGroupCriterionService->mutate($operations);  



Now I want to create a function that adds new  ProductOfferId to current partition, but I don't know how to retrieve the $root element without creating it again (and without doing a query to read the whole partition). What is the easiest way to get the root element of a product partition?

Thank you

googleadsapi...@google.com

unread,
May 9, 2019, 3:36:37 AM5/9/19
to adwor...@googlegroups.com, AdWords API and Google Ads API Forum
Hi Tommy,

Thanks for reaching out.

With regard to your question, you may use the get() method of AdGroupCriterionService to retrieve the parentCriterionId (which is the ID of the parent product partition subdivision). You can now use the returned ID of the parent product partition to add ProductOfferId.

Please let me know if you have further questions/clarifications.

Regards,
Ejay
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/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_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 adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@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+unsubscribe@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/e4dead6c-3125-4169-bc9e-e1be72f62a4e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

TommyTek

unread,
May 9, 2019, 3:43:12 AM5/9/19
to AdWords API and Google Ads API Forum
Hi Ejay,
  thank you for your help.

Something is still cloudy in my mind with product partitions :/ 
Would it be possible for you to provide the PHP code to get such info starting from the adgroup ID?

Later I'll have to discover how to delete a ProductOfferId too from the partition, I hope to have less troubles

Thank you very much :)

googleadsapi...@google.com

unread,
May 9, 2019, 6:41:40 AM5/9/19
to adwor...@googlegroups.com, AdWords API and Google Ads API Forum
Hi,

I'm afraid that there is no readily available code for this field. You may try to implement the field that I previously provided and you may return back if you encountered any issues/errors.

Regards,
Ejay
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/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_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 adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@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+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.

TommyTek

unread,
May 9, 2019, 9:07:38 AM5/9/19
to AdWords API and Google Ads API Forum
Hi,
    is there a way to filter criterions in order to pickup only the one with ParentCriterionId = NULL?

// Create predicates.
    $selector->setPredicates([
        new Predicate('AdGroupId', 'EQUALS', array($adGroupId)),    // <== ok
        new Predicate('CriterionUse', 'EQUALS', array('BIDDABLE')),     // <== ok
        new Predicate('PartitionType', 'EQUALS', array('SUBDIVISION')),      // <== NOT ok
        ]);

The statement above doesn't work because I get:

[SelectorError.INVALID_PREDICATE_FIELD_NAME @ ; trigger:'PartitionType']

Where can I find the list of fields I can use in Predicate?
By reading https://developers.google.com/adwords/api/docs/reference/v201809/AdGroupCriterionService.Predicate I should see somewhere that selector fields are filterable or not. Perhaps only these fields https://developers.google.com/adwords/api/docs/reference/v201809/AdGroupCriterionService.AdGroupCriterion can be filterable?

When fetching Criterions is it guaranteed that the first returned result is the root? so I can stop at the first and request only 1 record.

Thank you,
Tom

googleadsapi...@google.com

unread,
May 10, 2019, 6:58:41 AM5/10/19
to adwor...@googlegroups.com, AdWords API and Google Ads API Forum
Hi Tommy,

Thank you for your reply.

It seems that your latest question is the same with the one you've sent in your private reply. Please check my answer to this question on the private thread.

Regards,
Ejay
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/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_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 adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@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+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.

TommyTek

unread,
May 11, 2019, 4:13:33 PM5/11/19
to AdWords API and Google Ads API Forum
Hi,
 not sure it's the same question. What is the private thread?

thank you

googleadsapi...@google.com

unread,
May 13, 2019, 4:06:48 PM5/13/19
to AdWords API and Google Ads API Forum
Hello,

I am Ejay's colleague responding on this thread as he is not available. Below is the response from Ejay.

"With regard to your question on how to product partition, you may refer to the AddProductPartitionTree code example for PHP. The diagram shown here is a sample which shows how to use product groups in your campaigns.

With regard to your question about filtering the ParentCriterionId with null value, I am afraid that this is currently not possible to AdGroupCriterionService."

Please let me know if you have any further questions.

Regards,
Sai Teja, 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/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_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 adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@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+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
Reply all
Reply to author
Forward
0 new messages