Merchant Inventories API를 사용하여 매장 정보를 보관할 수 있습니다.
오프라인 제품을 최신 상태로 유지하세요. 여기에는 price
및 availability
업데이트가 포함됩니다.
제품을 더 이상 판매하지 않는 매장 삭제
서드 파티 제공업체인 경우 Merchant Inventories API를 사용하여 인벤토리를 판매할 수 있습니다. 판매자가 매장 재고를 업데이트할 수 있는 인터페이스를 만듭니다. 있습니다.
매장별 가격 및 재고 업데이트
사용
localInventories.insert
드림
제품의 매장 정보를 업데이트할 수 있습니다.
이 호출은
LocalInventory
드림
리소스이므로 모든 입력란을 포함해야 합니다.
코드를 위한 오프라인 제품
확인하시기 바랍니다.
기존 스토어 보기
이 섹션에서는 제품 또는 서비스와 연결된 매장을 확인하는 방법을 설명합니다. 있습니다.
제품별
사용
localInventories.list
드림
를 사용하여 특정 product
에 연결된 모든 오프라인 판매점 인벤토리를
있습니다. 이 호출은 전체 LocalInventory
리소스를 반환합니다. store_code
사용
속성을 사용하여 각 매장을 식별합니다.
다음은 제품의 오프라인 판매점 인벤토리를 나열하는 데 사용할 수 있는 샘플입니다.
자바
public static void listLocalInventories(Config config, String productId) throws Exception {
GoogleCredentials credential = new Authenticator().authenticate();
LocalInventoryServiceSettings localInventoryServiceSettings =
LocalInventoryServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
String parent = getParent(config.getMerchantId().toString(), productId);
try (LocalInventoryServiceClient localInventoryServiceClient =
LocalInventoryServiceClient.create(localInventoryServiceSettings)) {
// The parent product has the format: accounts/{account}/products/{product}
ListLocalInventoriesRequest request =
ListLocalInventoriesRequest.newBuilder().setParent(parent).build();
System.out.println("Sending list Local inventory request:");
ListLocalInventoriesPagedResponse response =
localInventoryServiceClient.listLocalInventories(request);
int count = 0;
// Iterates over all rows in all pages and prints the Local inventory
// in each row.
for (LocalInventory element : response.iterateAll()) {
System.out.println(element);
count++;
}
System.out.print("The following count of elements were returned: ");
System.out.println(count);
} catch (Exception e) {
System.out.println(e);
}
}
cURL
curl --location
'https://merchantapi.googleapis.com/inventories/v1beta/accounts/987654321/products/en~US~12345/localInventories' \
--header 'Authorization: Bearer <API_TOKEN>'
PHP
class ListLocalInventories
{
// ENSURE you fill in the merchant account and product ID for the sample to
// work.
private const PARENT = 'accounts/[INSERT_ACCOUNT_HERE]/products/[INSERT_PRODUCT_HERE]';
/**
* Lists all the local inventories of a given product.
*
* @param string $parent The `name` of the parent product to list `LocalInventory`
* resources for.
* Format: `accounts/{account}/products/{product}`
*/
function listLocalInventoriesSample(string $parent): void
{
// Gets the OAuth credentials to make the request.
$credentials = Authentication::useServiceAccountOrTokenFile();
// Creates options config containing credentials for the client to use.
$options = ['credentials' => $credentials];
// Creates a client.
$localInventoryServiceClient = new LocalInventoryServiceClient($options);
// Calls the API and catches and prints any network failures/errors.
try {
// Page size is set to the default value. If you are returned more
// responses than your page size, this code will automatically
// re-call the service with the `pageToken` until all responses
// are returned.
$parameters = ['pageSize' => 25000];
/** @var PagedListResponse $response */
$response =
$localInventoryServiceClient->listLocalInventories($parent, $parameters);
/** @var LocalInventory $element */
foreach ($response as $element) {
printf('LocalInventory data: %s%s', $element->serializeToJsonString(), PHP_EOL);
}
} catch (ApiException $ex) {
printf('Call failed with message: %s%s', $ex->getMessage(), PHP_EOL);
}
}
// Helper to execute the sample.
function callSample(): void
{
// Lists all the local inventories of the parent product.
$this->listLocalInventoriesSample($this::PARENT);
}
}
Python
from examples.authentication import generate_user_credentials
from google.shopping import merchant_inventories_v1beta
# ENSURE you fill in the merchant account and product ID for the sample to
# work.
_ACCOUNT = "[INSERT_ACCOUNT_HERE]"
_PRODUCT = "[INSERT_PRODUCT_HERE]"
_PARENT = f"accounts/{_ACCOUNT}/products/{_PRODUCT}"
def list_local_inventories():
"""Lists the `LocalInventory` resources for the given product.
The response might contain fewer items than specified by
`pageSize`. If `pageToken` was returned in previous request, it can be
used to obtain additional results.
`LocalInventory` resources are listed per product for a given account.
"""
# Gets OAuth Credentials.
credentials = generate_user_credentials.main()
# Creates a client.
client = merchant_inventories_v1beta.LocalInventoryServiceClient(
credentials=credentials)
# Creates the request.
# Page size is set to the default value.
request = merchant_inventories_v1beta.ListLocalInventoriesRequest(
parent=_PARENT,
page_size=25000
)
try:
# Makes the request and catch and print any error messages.
# If you are returned more responses than your page size, this code
# will automatically re-call the service with the `pageToken` until all
# responses are returned.
page_result = client.list_local_inventories(request=request)
# Print the response.
for response in page_result:
print(response)
except Exception as e:
print("List failed")
print(e)
계정별
내 계정과 연결된 모든 매장을 비즈니스에서 볼 수 있습니다. 프로필 또는 Google 마이 비즈니스 API를 참고하세요. 판매자 API를 사용하여 이 정보는 판매자 센터 계정에서 제공되므로 비즈니스 프로필.
매장 삭제
더 이상 제품을 판매하지 않는 매장을 삭제하는 방법은 다음과 같습니다.
제품
제품이 특정 매장에서 더 이상 판매되지 않는 경우
해당 매장의 인벤토리 항목을 생성합니다. 이때
localInventories.delete
드림
제품에서 특정 오프라인 판매점 인벤토리 항목을 삭제할 수 있습니다.
다음은 제품에서 오프라인 판매점 인벤토리 항목을 삭제하는 데 사용할 수 있는 샘플입니다.
자바
public static void deleteLocalInventory(Config config, String productId, String storeCode)
throws Exception {
GoogleCredentials credential = new Authenticator().authenticate();
LocalInventoryServiceSettings localInventoryServiceSettings =
LocalInventoryServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
String name =
LocalInventoryName.newBuilder()
.setAccount(config.getMerchantId().toString())
.setProduct(productId)
.setStoreCode(storeCode)
.build()
.toString();
try (LocalInventoryServiceClient localInventoryServiceClient =
LocalInventoryServiceClient.create(localInventoryServiceSettings)) {
DeleteLocalInventoryRequest request =
DeleteLocalInventoryRequest.newBuilder().setName(name).build();
System.out.println("Sending deleteLocalInventory request");
localInventoryServiceClient.deleteLocalInventory(request); // no response returned on success
System.out.println(
"Delete successful, note that it may take up to 30 minutes for the delete to update in"
+ " the system.");
} catch (Exception e) {
System.out.println(e);
}
}
cURL
curl --location --request DELETE
'https://merchantapi.googleapis.com/inventories/v1beta/accounts/987654321/products/en~US~12345/localInventories/123456' \
--header 'Authorization: Bearer <API_TOKEN>'
PHP
class DeleteLocalInventory
{
// ENSURE you fill in the merchant account, product, and region ID for the
// sample to work.
private const ACCOUNT = 'INSERT_ACCOUNT_ID_HERE';
private const PRODUCT = 'INSERT_PRODUCT_ID_HERE';
private const STORE_CODE = 'INSERT_STORE_CODE_HERE';
/**
* Deletes a specific local inventory of a given product.
*
* @param string $formattedName The name of the `LocalInventory` resource
* to delete.
* Format: `accounts/{account}/products/{product}/localInventories/{store_code}`
* Please see {@see LocalInventoryServiceClient::localInventoryName()}
* for help formatting this field.
*/
function deleteLocalInventorySample(string $formattedName): void
{
// Gets the OAuth credentials to make the request.
$credentials = Authentication::useServiceAccountOrTokenFile();
// Creates options config containing credentials for the client to use.
$options = ['credentials' => $credentials];
// Creates a client.
$localInventoryServiceClient = new LocalInventoryServiceClient($options);
// Calls the API and catches and prints any network failures/errors.
try {
$localInventoryServiceClient->deleteLocalInventory($formattedName);
print 'Delete call completed successfully.' . PHP_EOL;
} catch (ApiException $ex) {
printf('Call failed with message: %s%s', $ex->getMessage(), PHP_EOL);
}
}
/**
* Helper to execute the sample.
*/
function callSample(): void
{
// These variables are defined at the top of the file.
$formattedName = LocalInventoryServiceClient::localInventoryName(
$this::ACCOUNT,
$this::PRODUCT,
$this::STORE_CODE
);
// Deletes the specific local inventory of the parent product.
$this->deleteLocalInventorySample($formattedName);
}
}
Python
from examples.authentication import generate_user_credentials
from google.shopping import merchant_inventories_v1beta
# ENSURE you fill in the merchant account and product ID and store code
# for the sample to work.
_ACCOUNT = "[INSERT_ACCOUNT_HERE]"
_PRODUCT = "[INSERT_PRODUCT_HERE]"
_STORE_CODE = "[INSERT_STORE_CODE_HERE]"
_NAME = (f"accounts/{_ACCOUNT}/products/{_PRODUCT}/localInventories/"
f"{_STORE_CODE}")
def delete_local_inventory():
"""Deletes the specified `LocalInventory` resource from the given product.
It might take up to an hour for the `LocalInventory` to be deleted
from the specific product. Once you have received a successful delete
response, wait for that period before attempting a delete again.
"""
# Gets OAuth Credentials.
credentials = generate_user_credentials.main()
# Creates a client.
client = merchant_inventories_v1beta.LocalInventoryServiceClient(
credentials=credentials)
# Creates the request.
request = merchant_inventories_v1beta.DeleteLocalInventoryRequest(name=_NAME)
# Makes the request and catch and print any error messages.
try:
client.delete_local_inventory(request=request)
print("Delete successful")
except Exception as e:
print("Delete failed")
print(e)
이 호출은 지정한 매장에 관한 정보만 지정할 수 있습니다.
출처: 계정
계정에서 더 이상 제품을 판매하지 않는 매장을 삭제할 수 있습니다. 비즈니스 프로필에서 삭제합니다. 자세한 내용은 비즈니스 폐업 또는 삭제 참조하세요.