Hi, Thanks for the feedback. We created that example when the LINE 2 and LINE 3 placeholder fields <https://developers.google.com/adwords/api/docs/appendix/placeholders> were added to the API and AdWords. At that time, we had users with Feeds for sitelinks that:
- did not have those attributes, hence the add of FeedItemAttributes to the Feed - feed items without those attributes populated, hence the implementation of UpdateFeedItems() - a FeedMapping that was missing those attributes, hence the remove <https://github.com/googleads/googleads-php-lib/blob/master/examples/AdWords/v201406/AdvancedOperations/UpdateSitelinks.php#L201> and then add <https://github.com/googleads/googleads-php-lib/blob/master/examples/AdWords/v201406/AdvancedOperations/UpdateSitelinks.php#L218> of the FeedMapping in UpdateFeedMappings(). Note that the REMOVE/ADD approach is required (instead of a SET) because a FeedMapping is immutable. If you created your Feed and related objects using the AddSitelinks.php example after November 2013, then you are correct -- there's no need to run UpdateSitelinks. In fact, we may remove UpdateSitelinks in the near future since most people have probably added the LINE 2 and LINE 3 attributes to their feeds by now. Thanks, Josh, AdWords API Team On Wednesday, September 3, 2014 7:04:37 AM UTC-4, Tomas Rimkus wrote: > > Here are few issues I noticed with your UpdateSitelinks example (I'll be > referring specifically to PHP version of the example > <https://github.com/googleads/googleads-php-lib/blob/master/examples/AdWords/v201406/AdvancedOperations/UpdateSitelinks.php> > ): > > - There is no need to readd feed attributes which were already added > in "AddSitelinks" example. Adding attributes with the same name multiple > times causes ATTRIBUTE_NAMES_NOT_UNIQUE > error. AddLine1AndLine2Attributes() function should be removed and > UpdateSitelinksExample() function should be changed the following way: > > $feedService = $user->GetService('FeedService', ADWORDS_VERSION); > $feedItemService = $user->GetService('FeedItemService', ADWORDS_VERSION > ); > > $selector = new Selector(); > $selector->fields = array('Id', 'Attributes'); > $selector->predicates = array(); > $selector->predicates[0] = new Predicate('Id', 'EQUALS', array($feedId > )); > > $response = $feedService->get($selector); > $feed = $response->entries[0]; > > $line1Attribute = $feed->attributes[2]; > $line2Attribute = $feed->attributes[3]; > > UpdateFeedItems($feedItemService, $feedId, $line1Attribute, > $line2Attribute, > $feedItemDescriptions); > > - Inside UpdateFeedItems() function there is no need to call > $feedItemService->get() when the required feed items can be just created > as > new objects. The function should modified the following way: > > function UpdateFeedItems(AdWordsSoapClient $feedItemService, $feedId, > $line1Attribute, $line2Attribute, > $feedItemDescriptions) { > $feedItemIds = array_keys($feedItemDescriptions); > $itemOperations = array(); > foreach ($feedItemIds as $feedItemId) { > $feedItemDescription = $feedItemDescriptions[$feedItemId]; > $feedItem = new FeedItem(); > $feedItem->feedId = $feedId; > $feedItem->feedItemId = $feedItemId; > > $itemAttributeValues = array(); > $itemAttributeValues[0] = new FeedItemAttributeValue(); > $itemAttributeValues[0]->feedAttributeId = $line1Attribute->id > ; > $itemAttributeValues[0]->stringValue = $feedItemDescription[0 > ]; > > $itemAttributeValues[1] = new FeedItemAttributeValue(); > $itemAttributeValues[1]->feedAttributeId = $line2Attribute->id > ; > $itemAttributeValues[1]->stringValue = $feedItemDescription[1 > ]; > > $feedItem->attributeValues = $itemAttributeValues; > > $itemOperations[] = new FeedItemOperation($feedItem, 'SET'); > } > $feedItemService->mutate($itemOperations); > } > > - There is no need for UpdateFeedMappings() at the end > of UpdateSitelinksExample() function. The required mappings were already > created in AddSitelinks example. Adding same mappings multiple times > causes > MULTIPLE_MAPPINGS_FOR_PLACEHOLDER_TYPE error. > > -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ 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]. Visit this group at http://groups.google.com/group/adwords-api. To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/1b920778-130b-49e1-a082-589b07aa80d0%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
