examples/AdWords/v201809/Migration/MigrateToExtensionSettings.php
private static function getAttributeFieldMappings(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        $feedId,
        $placeholderTypeId
    ) {
        $feedMappingService = $adWordsServices->get($session, FeedMappingService::class);
        $page = $feedMappingService->query(
            sprintf(
                'SELECT FeedMappingId, AttributeFieldMappings WHERE FeedId="%d" '
                . 'AND PlaceholderType="%d" AND Status="ENABLED"',
                $feedId,
                $placeholderTypeId
            )
        );

        $attributeMappings = [];
        if ($page->getEntries() !== null) {
            // Normally, a feed attribute is mapped only to one field. However,
            // you may map it to more than one field if needed.
            foreach ($page->getEntries() as $feedMapping) {
                foreach ($feedMapping->getAttributeFieldMappings() as $attributeMapping) {
                    if (array_key_exists(
                        $attributeMapping->getFeedAttributeId(),
                        $attributeMappings
                    ) === false) {
                        $attributeMappings[$attributeMapping->getFeedAttributeId()] = [];
                    }
                    $attributeMappings[$attributeMapping->getFeedAttributeId()][] = $attributeMapping->getFieldId();
                }
            }
        }

        return $attributeMappings;
    }
private static function getAttributeFieldMappings(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        $feedId,
        $placeholderTypeId
    ) {
        $feedMappingService = $adWordsServices->get($session, FeedMappingService::class);
        $page = $feedMappingService->query(
            sprintf(
                'SELECT FeedMappingId, AttributeFieldMappings WHERE FeedId="%d" '
                . 'AND PlaceholderType="%d" AND Status="ENABLED"',
                $feedId,
                $placeholderTypeId
            )
        );

        $attributeMappings = [];
        if ($page->getEntries() !== null) {
            // Normally, a feed attribute is mapped only to one field. However,
            // you may map it to more than one field if needed.
            foreach ($page->getEntries() as $feedMapping) {
                foreach ($feedMapping->getAttributeFieldMappings() as $attributeMapping) {
                    if (array_key_exists(
                        $attributeMapping->getFeedAttributeId(),
                        $attributeMappings
                    ) === false) {
                        $attributeMappings[$attributeMapping->getFeedAttributeId()] = [];
                    }
                    $attributeMappings[$attributeMapping->getFeedAttributeId()][] = $attributeMapping->getFieldId();
                }
            }
        }

        return $attributeMappings;
    }
private static function getAttributeFieldMappings ( AdWordsServices $ adWordsServices , AdWordsSession $ session , $ feedId , $ placeholderTypeId ) { $ feedMappingService = $ adWordsServices -> get ( $ session , FeedMappingService :: class ) ; $ page = $ feedMappingService -> query ( sprintf ( 'SELECT FeedMappingId, AttributeFieldMappings WHERE FeedId="%d" ' . 'AND PlaceholderType="%d" AND Status="ENABLED"' , $ feedId , $ placeholderTypeId ) ) ; $ attributeMappings = [ ] ; if ( $ page -> getEntries ( ) !== null ) { // Normally, a feed attribute is mapped only to one field. However, // you may map it to more than one field if needed. foreach ( $ page -> getEntries ( ) as $ feedMapping ) { foreach ( $ feedMapping -> getAttributeFieldMappings ( ) as $ attributeMapping ) { if ( array_key_exists ( $ attributeMapping -> getFeedAttributeId ( ) , $ attributeMappings ) === false ) { $ attributeMappings [ $ attributeMapping -> getFeedAttributeId ( ) ] = [ ] ; } $ attributeMappings [ $ attributeMapping -> getFeedAttributeId ( ) ] [ ] = $ attributeMapping -> getFieldId ( ) ; } } } return $ attributeMappings ; }
Gets attribute field mappings from the specified feed and placeholder type.
Gets attribute field mappings from the specified feed and placeholder type .