Bölgeler

regions hizmeti, hem regionalinventory hem de shippingsettings hizmetleriyle hedef olarak kullanabileceğiniz coğrafi bölgeler oluşturup yönetmenize olanak tanır. Bölgeleri posta kodu koleksiyonları veya bazı ülkelerde önceden tanımlanmış coğrafi hedefler kullanarak tanımlayabilirsiniz. Bu kılavuzda, her bölge türünün nasıl tanımlanacağına dair örneklerin yanı sıra bölgesel fiyat geçersiz kılma işleminin nasıl oluşturulacağı açıklanmaktadır. Mevcut tüm yöntemler ve parametreler dahil olmak üzere regions hizmeti hakkında daha fazla bilgi için referans belgelerine bakın.

Bölge uygunluğu

Bölge oluşturduğunuzda, bölge hizmeti bölgeyi diğer Content API hizmetleriyle kullanıp kullanamayacağınızı belirler. Başarılı bir regions.create çağrısı için döndürülen yanıt nesnesi, bölgeyi sırasıyla regionalinventory ve shippingsettings hizmetleriyle kullanıp kullanamayacağınızı belirten iki boole alanı (regionalInventoryEligible ve shippingEligible) içerir.

regionalInventoryEligible

regionalinventory hizmetiyle kullanılmaya uygun olması için bir bölgenin aşağıdaki ölçütleri karşılaması gerekir:

  • Bölge oluştururken belirttiğiniz regionId yalnızca rakam içermeli ve en az 6 haneli olmalıdır.
  • Bölge, coğrafi alan ve online nüfus için minimum boyut koşullarını karşılamalıdır.

shippingEligible

shippingsettings hizmetiyle kullanılmaya uygun olması için bir bölgenin aşağıdaki ölçütleri karşılaması gerekir:

  • Bölge, posta kodları kullanılarak tanımlanmalıdır.
  • Bölge, shippingsettings hizmetin desteklediği bir ülkede olmalıdır.

Örnekler

Java'da yeni bir bölge oluşturmak için kullanabileceğiniz tam kod örneğini aşağıda bulabilirsiniz:

// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package shopping.content.v2_1.samples.regions;

import com.google.api.client.googleapis.json.GoogleJsonResponseException;
import com.google.api.services.content.model.Region;
import com.google.api.services.content.model.RegionPostalCodeArea;
import com.google.api.services.content.model.RegionPostalCodeAreaPostalCodeRange;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import shopping.content.v2_1.samples.ContentSample;

/**
 * Creates a region. The region created here can be used with the regional inventory service.
 * Regional availability and pricing lets you provide product availability and variable pricing
 * based on your business presence and the location of your customer base. Regional availability and
 * pricing is available for products advertised through Shopping ads on Google Search, and listed in
 * free listings on the Shopping tab.
 */
public class RegionCreateSample extends ContentSample {
  public RegionCreateSample(String[] args) throws IOException {
    super(args);
  }

  @Override
  public void execute() throws IOException {
    checkNonMCA();

    // Creates a List of Postal Code Area Postal Code Ranges.
    // This allows you to flexibly define regions as combinations of postal code
    // ranges. Each postal code range in the list has its own start and end zip code.
    List<RegionPostalCodeAreaPostalCodeRange> postalCodeRanges =
        new ArrayList<RegionPostalCodeAreaPostalCodeRange>();

    // Creates a new postal code range from two postal code values.
    // This range is equivalent to all postal codes in the USA state of New York (00501 - 14925)
    RegionPostalCodeAreaPostalCodeRange postalCodeRange =
        new RegionPostalCodeAreaPostalCodeRange().setBegin("00501").setEnd("14925");

    // Adds the NY State postal code range into the list of postal code ranges that a postal
    // code area accepts.
    postalCodeRanges.add(postalCodeRange);

    // Creates Postal Code Area for the Region that will be inserted, using the NY State postal code
    // ranges, and the US CLDR territory/country code that the postal code ranges applies to.
    RegionPostalCodeArea postalCodeArea =
        new RegionPostalCodeArea().setPostalCodes(postalCodeRanges).setRegionCode("US");

    // Creates a region with example values for displayName and postalCodeArea
    Region region = new Region().setDisplayName("NYState").setPostalCodeArea(postalCodeArea);

    // Tries to create the region, and catches any exceptions
    try {
      System.out.println("Creating region");
      Region result =
          content
              .regions()
              .create(this.config.getMerchantId().longValue(), region)
              .setRegionId("12345678") // User-defined, numeric, minimum of 6 digits
              .execute();
      System.out.println("Listing succesfully created region");
      System.out.println(result);
    } catch (GoogleJsonResponseException e) {
      checkGoogleJsonResponseException(e);
    }
  }

  public static void main(String[] args) throws IOException {
    new RegionCreateSample(args).execute();
  }
}

Posta kodlarını kullanarak bölge oluşturma

Posta kodu koleksiyonu olarak tanımlanan bir bölge oluşturmak için regions.create yöntemini kullanabilirsiniz. Aşağıdaki örnekte, bir posta kodu aralığı belirtilerek ABD'nin Arizona eyaleti için yeni bir bölge oluşturuluyor.

Bölgeyi oluşturmak için aşağıdaki URL ve istek gövdesiyle POST isteğinde bulunun:

https://shoppingcontent.googleapis.com/content/v2.1/merchantId/regions?regionId=456789
{
  postalCodeArea: {
    regionCode: "US",
    postalCodes: [
      {
        begin: "850*",
        end: "860*"
      }
    ]
   }
}

Merchant Center hesabı başına regions ve shippingsettings için 2 MB'lık kesin bir veri sınırı vardır. Kargo ve bölge ayarları bir MM'den tüm alt hesaplarına dahili olarak kopyalandığından daha büyük MM'lerde depolama alanı sınırınıza hızlıca ulaşabilirsiniz. Bu durumda, regions ve shippingsettings'yi satıcı kimliği düzeyinde yönetmek geçici bir çözümdür. Bölge kotanızı 2 MB sınırının üzerine çıkarmanın bir yolu yoktur.

Coğrafi hedefleme kullanarak bölge oluşturma

Brezilya ve Rusya'daki bölgeler için, önceden tanımlanmış coğrafi alanlar olan coğrafi hedefler koleksiyonu olarak tanımlanan bir bölge oluşturmak üzere regions.create yöntemini de kullanabilirsiniz. Coğrafi hedef türlerine örnek olarak ülkeler, eyaletler, şehirler, mahalleler ve havalimanları verilebilir. Ancak regions hizmeti şu anda yalnızca Brezilya için "Eyalet", Rusya için ise "Bölge" türünü desteklemektedir. regions hizmetiyle kullanılabilecek coğrafi hedeflemeler de dahil olmak üzere tüm coğrafi hedef kimliklerinin CSV dosyasını indirmek için Coğrafi Hedefler bölümüne bakın. Aşağıdaki örnekte, üç Brezilya eyaletinin coğrafi hedef kimlikleri sağlanarak yeni bir bölge oluşturulmaktadır.

Bölgeyi oluşturmak için aşağıdaki URL'yi ve istek gövdesini kullanarak bir POST isteği gönderin:

https://shoppingcontent.googleapis.com/content/v2.1/merchantId/regions?regionId=123456
{
  geoTargetAreas: {
    geotargetCriteriaId: [20106, 20102, 20101] //Sao Paulo, Rio de Janeiro, Parana
  }
}

Bölgesel fiyat geçersiz kılmaları oluşturmak için bölgeleri kullanma

Bölge oluşturduğunuzda regions hizmeti, regionId ve iki uygunluk durumu alanı içeren bir yanıt nesnesi döndürür. regionalInventoryEligible değeri true ise bölge için farklı bir fiyat belirleyen geçersiz kılma işlemi oluşturmak üzere regionaliventory hizmetini kullanabilirsiniz. Aşağıdaki örnekte, yukarıdaki örnekte oluşturulan ve regionId değeri "456789" olan posta koduna dayalı bölge kullanılarak bölgesel fiyat geçersiz kılma işlemi oluşturulmaktadır.

Geçersiz kılma oluşturmak için aşağıdaki URL'yi ve istek gövdesini kullanarak bir POST isteği gönderin:

https://shoppingcontent.googleapis.com/content/v2.1/merchantId/products/{productId}/regionalinventory
{
  “regionId”: "456789"
  “price”: {
    value: 10
    currency: “USD”
  },
  “availability”: “in stock”
}