Local Feeds Partnership (LFP) की सेवा देने वाली कंपनियों को मैनेज करना

Local feeds partnership program की मदद से, खुदरा दुकानदार स्थानीय इन्वेंट्री विज्ञापनों और मुफ़्त में दिखाई जाने वाली स्थानीय लिस्टिंग में हिस्सा ले सकते हैं. ऐसा करने के लिए, उन्हें प्राइमरी और स्थानीय प्रॉडक्ट इन्वेंट्री फ़ीड बनाने की ज़रूरत नहीं पड़ेगी. डेटा मुहैया कराने वाली भरोसेमंद कंपनियां, खुदरा दुकानदारों की ओर से Google को बिक्री या इन्वेंट्री का डेटा दे सकती हैं.

ज़रूरी शर्तें

इस सेक्शन में एपीआई के तरीकों का इस्तेमाल करने के लिए, पहले अपने स्थानीय इन्वेंट्री विज्ञापन (एलआईए) या मुफ़्त में दिखाई जाने वाली स्थानीय लिस्टिंग (एफ़एलएल) प्रोग्राम सेट अप करें. ज़्यादा जानकारी के लिए, ऑल-चैनल बिक्री की सेटिंग मैनेज करना लेख पढ़ें.

LFP की सेवा देने वाली उपलब्ध कंपनियां ढूंढना

किसी देश में, एलएफ़पी की सेवा देने वाली सभी कंपनियों की जानकारी पाने के लिए, lfpProviders.findLfpProviders का इस्तेमाल करें.

POST
https://merchantapi.googleapis.com/accounts/v1beta/accounts/{ACCOUNT_ID}/omnichannelSettings/{REGION_CODE}/lfpProviders:find

इनकी जगह ये डालें:

  • {ACCOUNT_ID}: आपके Merchant Center खाते का यूनीक आइडेंटिफ़ायर
  • {REGION_CODE}: Common Locale Data Repository (CLDR) प्रोजेक्ट की तय की गई सूची में से, देश/इलाके का कोड

सही रिस्पॉन्स का सैंपल:

200 OK
{
  "lsfProviders": [
    {
      "name": "accounts/{ACCOUNT}/omnichannelSettings/{REGION_CODE}/lsfProviders/12345",
      "regionCode": {REGION_CODE},
      "displayName": "LFP Provider 1"
    }, {
      "name": "accounts/{ACCOUNT}/omnichannelSettings/{REGION_CODE}/lsfProviders/67890",
      "regionCode": {REGION_CODE},
      "displayName": "LFP Provider 6"
    }
  ],
  "nextPageToken": 50
}

यहां कोड का सैंपल दिया गया है:

package shopping.merchant.samples.accounts.v1beta;

// [START merchantapi_find_lfp_providers]
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1beta.FindLfpProvidersRequest;
import com.google.shopping.merchant.accounts.v1beta.LfpProvider;
import com.google.shopping.merchant.accounts.v1beta.LfpProvidersServiceClient;
import com.google.shopping.merchant.accounts.v1beta.LfpProvidersServiceClient.FindLfpProvidersPagedResponse;
import com.google.shopping.merchant.accounts.v1beta.LfpProvidersServiceSettings;
import com.google.shopping.merchant.accounts.v1beta.OmnichannelSettingName;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;

/** This class demonstrates how to get the Lfp Providers for a given Merchant Center account */
public class FindLfpProvidersSample {

  public static void findLfpProviders(Config config, String regionCode)
      throws Exception {

    // Obtains OAuth token based on the user's configuration.
    GoogleCredentials credential = new Authenticator().authenticate();

    // Creates service settings using the retrieved credentials.
    LfpProvidersServiceSettings lfpProvidersServiceSettings =
        LfpProvidersServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    // Gets the account ID from the config file.
    String accountId = config.getAccountId().toString();
    // Creates parent to identify the omnichannelSetting from which to list all Lfp Providers.
    String parent =
        OmnichannelSettingName.newBuilder()
            .setAccount(accountId)
            .setOmnichannelSetting(regionCode)
            .build()
            .toString();

    // Calls the API and catches and prints any network failures/errors.
    try (LfpProvidersServiceClient lfpProvidersServiceClient =
        LfpProvidersServiceClient.create(lfpProvidersServiceSettings)) {
      FindLfpProvidersRequest request =
          FindLfpProvidersRequest.newBuilder().setParent(parent).build();

      System.out.println("Sending find LFP providers request:");
      FindLfpProvidersPagedResponse response = lfpProvidersServiceClient.findLfpProviders(request);

      int count = 0;

      // Iterates over all the entries in the response.
      for (LfpProvider lfpProvider : response.iterateAll()) {
        System.out.println(lfpProvider);
        count++;
      }
      System.out.println(String.format("The following count of elements were returned: %d", count));
    } catch (Exception e) {
      System.out.println("An error has occurred: ");
      System.out.println(e);
    }
  }

  public static void main(String[] args) throws Exception {
    Config config = Config.load();

    // The country you're targeting at.
    String regionCode = "{REGION_CODE}";

    findLfpProviders(config, regionCode);
  }
}
// [END merchantapi_find_lfp_providers]

LFP पार्टनरशिप बनाने के लिए, lfpProviders.LinkLfpProvider का इस्तेमाल करें:

POST
https://merchantapi.googleapis.com/accounts/v1beta/accounts/{ACCOUNT_ID}/omnichannelSettings/{REGION_CODE}/lfpProviders/{LFP_PROVIDER}:linkLfpProvider
{
  "externalAccountId": "{EXTERNAL_ACCOUNT_ID}",
}

इनकी जगह ये डालें:

  • {ACCOUNT_ID}: आपके Merchant Center खाते का यूनीक आइडेंटिफ़ायर
  • {LFP_PROVIDER}: एलएफ़पी की सेवा देने वाली कंपनी का आईडी, जो पिछले चरण में मिला था. उदाहरण के लिए, एलएफ़पी की सेवा देने वाली पहली कंपनी के लिए यह 12345 होगा.
  • {EXTERNAL_ACCOUNT_ID}: वह बाहरी खाता आईडी जिससे एलएफ़पी प्रोवाइडर को कारोबारी की जानकारी मिलती है.

इस कोड सैंपल में, LFP प्रोवाइडर को लिंक करने का तरीका बताया गया है:

package shopping.merchant.samples.accounts.v1beta;

// [START merchantapi_link_lfp_provider]
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1beta.LfpProvidersServiceClient;
import com.google.shopping.merchant.accounts.v1beta.LfpProvidersServiceSettings;
import com.google.shopping.merchant.accounts.v1beta.LinkLfpProviderRequest;
import shopping.merchant.samples.utils.Authenticator;

/** This class demonstrates how to link the Lfp Providers for a given Merchant Center account */
public class LinkLfpProviderSample {

  public static void linkLfpProvider(String lfpProviderName, String externalAccountId)
      throws Exception {

    // Obtains OAuth token based on the user's configuration.
    GoogleCredentials credential = new Authenticator().authenticate();

    // Creates service settings using the retrieved credentials.
    LfpProvidersServiceSettings lfpProvidersServiceSettings =
        LfpProvidersServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    // Calls the API and catches and prints any network failures/errors.
    try (LfpProvidersServiceClient lfpProvidersServiceClient =
        LfpProvidersServiceClient.create(lfpProvidersServiceSettings)) {
      LinkLfpProviderRequest request =
          LinkLfpProviderRequest.newBuilder()
              .setName(lfpProviderName)
              .setExternalAccountId(externalAccountId)
              .build();

      System.out.println("Sending link lfp provider request:");
      // Empty response returned on success.
      lfpProvidersServiceClient.linkLfpProvider(request);
      System.out.println(String.format("Successfully linked to LFP provider: %s", lfpProviderName));
    } catch (Exception e) {
      System.out.println("An error has occurred: ");
      System.out.println(e);
    }
  }

  public static void main(String[] args) throws Exception {
    // The name of the lfp provider you want to link, returned from `lfpProviders.findLfpProviders`.
    // It's of the form
    // "accounts/{account_id}/omnichannelSettings/{omnichannel_settings}/lfpProviders/{lfp_provider}".
    String lfpProviderName = "{LFP_PROVIDER_NAME}";
    // External account ID by which this merchant is known to the LFP provider.
    String externalAccountId = "{EXTERNAL_ACCOUNT_ID}";

    linkLfpProvider(lfpProviderName, externalAccountId);
  }
}
// [END merchantapi_link_lfp_provider]

``` You can check your LFP status by calling `omnichannelSettings.get` and
checking the `LfpLink` field.

To learn more about how to use LFP, see [Local feeds partnership
API](https://developers.google.com/merchant/api/guides/local-feeds-partnership/overview).