अपने प्रॉडक्ट को बार-बार अपडेट करें

Products sub-API की मदद से, अपने मौजूदा प्रॉडक्ट में आंशिक अपडेट किए जा सकते हैं. यह सुविधा, कीमत और खरीदारी के लिए उपलब्धता जैसी जानकारी में अक्सर होने वाले बदलावों के लिए सबसे सही है. इसकी वजह यह है कि छोटे-मोटे बदलावों के लिए, पूरे प्रॉडक्ट को फिर से सबमिट करने की ज़रूरत नहीं पड़ती. हालांकि, आपको प्रॉडक्ट को नियमित तौर पर फिर से डालना चाहिए, ताकि यह पक्का किया जा सके कि सभी प्रॉडक्ट डेटा सिंक हो गया है.

इस गाइड में, productinputs.patch तरीके का इस्तेमाल करके अपने प्रॉडक्ट अपडेट करने का तरीका बताया गया है.

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

किसी प्रॉडक्ट की जानकारी अपडेट करने से पहले, आपको इनकी ज़रूरत होगी:

प्रॉडक्ट की खास जानकारी अपडेट करना

अगर आपको किसी प्रॉडक्ट की कुछ जानकारी में बदलाव करना है, जैसे कि उसकी कीमत या उपलब्धता, तो productInputs.patch तरीके का इस्तेमाल करें. इससे आपको प्रॉडक्ट की पूरी जानकारी फिर से सबमिट नहीं करनी पड़ेगी.

updateMask पैरामीटर में जाकर, यह तय किया जा सकता है कि आपको किन फ़ील्ड में बदलाव करना है. updateMask में, कॉमा लगाकर अलग किए गए उन फ़ील्ड की सूची होती है जिन्हें आपको अपडेट करना है. patch तरीका इस तरह काम करता है:

  • updateMask और बॉडी में मौजूद फ़ील्ड: इन फ़ील्ड को नई वैल्यू के साथ अपडेट किया जाता है.
  • updateMask में मौजूद फ़ील्ड, लेकिन मुख्य हिस्से में नहीं: इन फ़ील्ड को प्रॉडक्ट इनपुट से मिटा दिया जाता है.
  • updateMask में मौजूद नहीं हैं: इन फ़ील्ड में कोई बदलाव नहीं किया गया है.
  • updateMask पैरामीटर शामिल नहीं किया गया है: अनुरोध के मुख्य हिस्से में दिए गए सभी फ़ील्ड अपडेट किए जाते हैं. अनुरोध के मुख्य हिस्से में दिए गए फ़ील्ड, प्रॉडक्ट इनपुट से नहीं मिटाए जाते.

यहां अपडेट से पहले के प्रॉडक्ट डेटा का उदाहरण दिया गया है:

{
  "name": "accounts/{ACCOUNT_ID}/productInputs/en~US~SKU12345",
  "product": "accounts/{ACCOUNT_ID}/products/en~US~SKU12345",
  "offerId": "SKU12345",
  "contentLanguage": "en",
  "feedLabel": "US",
  "productAttributes": {
    "title": "Classic Cotton T-Shirt",
    "description": "A comfortable, durable, and stylish t-shirt made from 100% cotton.",
    "link": "https://www.example.com/p/SKU12345",
    "availability": "IN_STOCK",
    "price": {
      "amountMicros": "15990000",
      "currencyCode": "USD"
    },
    "condition": "NEW",
    "gtins": [
      "9780007350896"
    ],
    "imageLink": "https://www.example.com/image/SKU12345"
  }
}

इस उदाहरण में, किसी प्रॉडक्ट के title और availability को अपडेट किया गया है. साथ ही, उसके imageLink को मिटाया गया है. description और price, updateMask में नहीं हैं. इसलिए, इनमें कोई बदलाव नहीं होगा.

PATCH https://merchantapi.googleapis.com/products/v1/accounts/{ACCOUNT_ID}/productInputs/en~US~SKU12345?updateMask=productAttributes.title,productAttributes.availability,productAttributes.imageLink&dataSource=accounts/{ACCOUNT_ID}/dataSources/{DATASOURCE_ID}
{
 "productAttributes": {
   "title": "Classic Cotton T-Shirt - New Edition",
   "availability": "OUT_OF_STOCK",
    "description": "A comfortable T-shirt from premium cotton, newer edition.",
    "price": {
      "amountMicros": "9990000",
      "currencyCode": "USD"
    }
 }
}

कॉल पूरा होने पर, अपडेट किया गया ProductInput संसाधन दिखता है. title और availability को अपडेट किया जाता है. साथ ही, imageLink को हटा दिया जाता है, क्योंकि यह updateMask में मौजूद था, लेकिन अनुरोध के मुख्य हिस्से में नहीं था. description और price में कोई बदलाव नहीं हुआ है, क्योंकि ये updateMask में शामिल नहीं थे.

{
  "name": "accounts/{ACCOUNT_ID}/productInputs/en~US~SKU12345",
  "product": "accounts/{ACCOUNT_ID}/products/en~US~SKU12345",
  "offerId": "SKU12345",
  "contentLanguage": "en",
  "feedLabel": "US",
  "productAttributes": {
    "title": "Classic Cotton T-Shirt - New Edition",
    "description": "A comfortable, durable, and stylish t-shirt made from 100% cotton.",
    "link": "https://www.example.com/p/SKU12345",
    "availability": "OUT_OF_STOCK",
    "price": {
      "amountMicros": "15990000",
      "currencyCode": "USD"
    },
    "condition": "NEW",
    "gtins": [
      "9780007350896"
    ],
  }
}

यहां दिए गए कोड के सैंपल में, किसी प्रॉडक्ट की जानकारी अपडेट करने का तरीका बताया गया है.

Java

import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.protobuf.FieldMask;
import com.google.shopping.merchant.datasources.v1.DataSourceName;
import com.google.shopping.merchant.products.v1.Availability;
import com.google.shopping.merchant.products.v1.Condition;
import com.google.shopping.merchant.products.v1.ProductAttributes;
import com.google.shopping.merchant.products.v1.ProductInput;
import com.google.shopping.merchant.products.v1.ProductInputName;
import com.google.shopping.merchant.products.v1.ProductInputsServiceClient;
import com.google.shopping.merchant.products.v1.ProductInputsServiceSettings;
import com.google.shopping.merchant.products.v1.UpdateProductInputRequest;
import com.google.shopping.type.CustomAttribute;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;

/** This class demonstrates how to update a product input */
public class UpdateProductInputSample {

  public static void updateProductInput(Config config, String productId, String dataSourceId)
      throws Exception {

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

    // Creates service settings using the credentials retrieved above.
    ProductInputsServiceSettings productInputsServiceSettings =
        ProductInputsServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    // Creates product name to identify product.
    String name =
        ProductInputName.newBuilder()
            .setAccount(config.getAccountId().toString())
            .setProductinput(productId)
            .build()
            .toString();

    // Just productAttributes and customAttributes can be updated
    FieldMask fieldMask =
        FieldMask.newBuilder()
            .addPaths("product_attributes.title")
            .addPaths("product_attributes.description")
            .addPaths("product_attributes.link")
            .addPaths("product_attributes.image_link")
            .addPaths("product_attributes.availability")
            .addPaths("product_attributes.condition")
            .addPaths("product_attributes.gtins")
            .addPaths("custom_attributes.mycustomattribute")
            .build();

    // Calls the API and catches and prints any network failures/errors.
    try (ProductInputsServiceClient productInputsServiceClient =
        ProductInputsServiceClient.create(productInputsServiceSettings)) {

      ProductAttributes attributes =
          ProductAttributes.newBuilder()
              .setTitle("A Tale of Two Cities")
              .setDescription("A classic novel about the French Revolution")
              .setLink("https://exampleWebsite.com/tale-of-two-cities.html")
              .setImageLink("https://exampleWebsite.com/tale-of-two-cities.jpg")
              .setAvailability(Availability.IN_STOCK)
              .setCondition(Condition.NEW)
              .addGtins("9780007350896")
              .build();

      // The datasource can be either a primary or supplemental datasource.
      String dataSource =
          DataSourceName.newBuilder()
              .setAccount(config.getAccountId().toString())
              .setDatasource(dataSourceId)
              .build()
              .toString();

      UpdateProductInputRequest request =
          UpdateProductInputRequest.newBuilder()
              .setUpdateMask(fieldMask)
              // You can only update product attributes and custom_attributes
              .setDataSource(dataSource)
              .setProductInput(
                  ProductInput.newBuilder()
                      .setName(name)
                      .setProductAttributes(attributes)
                      .addCustomAttributes(
                          CustomAttribute.newBuilder()
                              .setName("mycustomattribute")
                              .setValue("Example value")
                              .build())
                      .build())
              .build();

      System.out.println("Sending update ProductInput request");
      ProductInput response = productInputsServiceClient.updateProductInput(request);
      System.out.println("Updated ProductInput Name below");
      // The last part of the product name will be the product ID assigned to a product by Google.
      // Product ID has the format `contentLanguage~feedLabel~offerId`
      System.out.println(response.getName());
      System.out.println("Updated Product below");
      System.out.println(response);
    } catch (Exception e) {
      System.out.println(e);
    }
  }

  public static void main(String[] args) throws Exception {
    Config config = Config.load();
    // An ID assigned to a product by Google. In the format
    // contentLanguage~feedLabel~offerId
    String productId = "en~label~sku123"; // Replace with your product ID.

    // Identifies the data source that will own the product input.
    String dataSourceId = "{INSERT_DATASOURCE_ID}"; // Replace with your datasource ID.

    updateProductInput(config, productId, dataSourceId);
  }
}

PHP

use Google\ApiCore\ApiException;
use Google\Protobuf\FieldMask;
use Google\Shopping\Merchant\Products\V1\Availability;
use Google\Shopping\Merchant\Products\V1\Condition;
use Google\Shopping\Merchant\Products\V1\ProductAttributes;
use Google\Shopping\Merchant\Products\V1\Client\ProductInputsServiceClient;
use Google\Shopping\Merchant\Products\V1\ProductInput;
use Google\Shopping\Merchant\Products\V1\UpdateProductInputRequest;
use Google\Shopping\Type\CustomAttribute;

/**
 * This class demonstrates how to update a product input.
 */
class UpdateProductInputSample
{
    // An ID assigned to a product by Google. In the format
    // contentLanguage~feedLabel~offerId
    // Please ensure this product ID exists for the update to succeed.
    private const PRODUCT_ID = "online~en~label~sku123";

    // Identifies the data source that will own the product input.
    // Please ensure this data source ID exists.
    private const DATASOURCE_ID = "<INSERT_DATASOURCE_ID>";

    /**
     * Helper function to construct the full product input resource name.
     *
     * @param string $accountId The merchant account ID.
     * @param string $productInputId The product input ID (e.g., "online~en~label~sku123").
     * @return string The full product input resource name.
     */
    private static function getProductInputName(string $accountId, string $productInputId): string
    {
        return sprintf("accounts/%s/productInputs/%s", $accountId, $productInputId);
    }

    /**
     * Helper function to construct the full data source resource name.
     *
     * @param string $accountId The merchant account ID.
     * @param string $dataSourceId The data source ID.
     * @return string The full data source resource name.
     */
    private static function getDataSourceName(string $accountId, string $dataSourceId): string
    {
        return sprintf("accounts/%s/dataSources/%s", $accountId, $dataSourceId);
    }

    /**
     * Updates an existing product input in your Merchant Center account.
     *
     * @param array $config The configuration array containing the account ID.
     * @param string $productId The ID of the product input to update.
     * @param string $dataSourceId The ID of the data source.
     */
    public static function updateProductInput(
        array $config,
        string $productId,
        string $dataSourceId
    ): 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 ProductInputsServiceClient.
        $productInputsServiceClient = new ProductInputsServiceClient($options);

        // Construct the full resource name of the product input to be updated.
        $name = self::getProductInputName($config['accountId'], $productId);

        // Define the FieldMask to specify which fields to update.
        // Only 'attributes' and 'custom_attributes' can be specified in the
        // FieldMask for product input updates.
        $fieldMask = new FieldMask([
            'paths' => [
                "product_attributes.title",
                "product_attributes.description",
                "product_attributes.link",
                "product_attributes.image_link",
                "product_attributes.availability",
                "product_attributes.condition",
                "product_attributes.gtin",
                "custom_attributes.mycustomattribute" // Path for a specific custom attribute
            ]
        ]);

        // Calls the API and handles any network failures or errors.
        try {
            // Define the new attributes for the product.
            $attributes = new ProductAttributes([
                'title' => 'A Tale of Two Cities 3',
                'description' => 'A classic novel about the French Revolution',
                'link' => 'https://exampleWebsite.com/tale-of-two-cities.html',
                'image_link' => 'https://exampleWebsite.com/tale-of-two-cities.jpg',
                'availability' => Availability::IN_STOCK,
                'condition' => Condition::PBNEW,
                'gtins' => ['9780007350896'] // GTIN is a repeated field.
            ]);

            // Construct the full data source name.
            // This specifies the data source context for the update.
            $dataSource = self::getDataSourceName($config['accountId'], $dataSourceId);

            // Create the ProductInput object with the desired updates.
            // The 'name' field must match the product input being updated.
            $productInput = new ProductInput([
                'name' => $name,
                'product_attributes' => $attributes,
                'custom_attributes' => [ // Provide the list of custom attributes.
                    new CustomAttribute([
                        'name' => 'mycustomattribute',
                        'value' => 'Example value'
                    ])
                ]
            ]);

            // Create the UpdateProductInputRequest.
            $request = new UpdateProductInputRequest([
                'update_mask' => $fieldMask,
                'data_source' => $dataSource,
                'product_input' => $productInput
            ]);

            print "Sending update ProductInput request\n";
            // Make the API call to update the product input.
            $response = $productInputsServiceClient->updateProductInput($request);

            print "Updated ProductInput Name below\n";
            // The name of the updated product input.
            // The last part of the product name is the product ID (e.g., contentLanguage~feedLabel~offerId).
            print $response->getName() . "\n";
            print "Updated Product below\n";
            // Print the full updated product input object.
            print_r($response);

        } catch (ApiException $e) {
            printf("ApiException caught: %s\n", $e->getMessage());
        }
    }

    /**
     * Executes the UpdateProductInput sample.
     */
    public function callSample(): void
    {
        $config = Config::generateConfig();
        $productId = self::PRODUCT_ID;
        $dataSourceId = self::DATASOURCE_ID;

        self::updateProductInput($config, $productId, $dataSourceId);
    }
}

// Run the script.
$sample = new UpdateProductInputSample();
$sample->callSample();

Python

"""A module to update a product input."""

from examples.authentication import configuration
from examples.authentication import generate_user_credentials
from google.protobuf import field_mask_pb2
from google.shopping.merchant_products_v1 import Availability
from google.shopping.merchant_products_v1 import Condition
from google.shopping.merchant_products_v1 import ProductAttributes
from google.shopping.merchant_products_v1 import ProductInput
from google.shopping.merchant_products_v1 import ProductInputsServiceClient
from google.shopping.merchant_products_v1 import UpdateProductInputRequest
from google.shopping.type import CustomAttribute


# Fetches the Merchant Center account ID from the authentication examples.
# This ID is needed to construct resource names for the API.
_ACCOUNT_ID = configuration.Configuration().read_merchant_info()


def update_product_input(account_id: str, product_id: str, data_source_id: str):
  """Updates an existing product input for a specific account.

  Args:
    account_id: The Merchant Center account ID.
    product_id: The ID of the product input to update. This ID is assigned by
      Google and has the format `contentLanguage~feedLabel~offerId`.
    data_source_id: The ID of the data source that owns the product input.
  """

  # Obtains OAuth credentials for authentication.
  credentials = generate_user_credentials.main()

  # Creates a ProductInputsServiceClient instance.
  client = ProductInputsServiceClient(credentials=credentials)

  # Constructs the full resource name for the product input.
  # Format: accounts/{account}/productInputs/{productinput}
  name = f"accounts/{account_id}/productInputs/{product_id}"

  # Defines the FieldMask to specify which fields of the product input
  # are being updated. Only 'attributes' and 'custom_attributes' can be updated.
  field_mask = field_mask_pb2.FieldMask(
      paths=[
          "product_attributes.title",
          "product_attributes.description",
          "product_attributes.link",
          "product_attributes.image_link",
          "product_attributes.availability",
          "product_attributes.condition",
          "product_attributes.gtins",
          "custom_attributes.mycustomattribute",
      ]
  )

  # Prepares the new attribute values for the product.
  attributes = ProductAttributes(
      title="A Tale of Two Cities updated",
      description="A classic novel about the French Revolution",
      link="https://exampleWebsite.com/tale-of-two-cities.html",
      image_link="https://exampleWebsite.com/tale-of-two-cities.jpg",
      availability=Availability.IN_STOCK,
      condition=Condition.NEW,
      gtins=["9780007350896"],  # GTIN is a repeated field.
  )

  # Constructs the full resource name for the data source.
  # The data source can be primary or supplemental.
  # Format: accounts/{account}/dataSources/{datasource}
  data_source = f"accounts/{account_id}/dataSources/{data_source_id}"

  # Prepares the ProductInput object with the updated information.
  product_input_data = ProductInput(
      name=name,
      product_attributes=attributes,
      custom_attributes=[
          CustomAttribute(
              name="mycustomattribute", value="Example value"
          )
      ],
  )

  # Creates the UpdateProductInputRequest.
  request = UpdateProductInputRequest(
      update_mask=field_mask,
      data_source=data_source,
      product_input=product_input_data,
  )

  # Sends the update request to the API.
  try:
    print("Sending update ProductInput request")
    response = client.update_product_input(request=request)
    print("Updated ProductInput Name below")
    # The response includes the name of the updated product input.
    # The last part of the product name is the product ID assigned by Google.
    print(response.name)
    print("Updated Product below")
    print(response)
  except RuntimeError as e:
    # Catches and prints any errors that occur during the API call.
    print(e)


if __name__ == "__main__":
  # The ID of the product to be updated.
  # This ID is assigned by Google and typically follows the format:
  # contentLanguage~feedLabel~offerId
  # Replace with an actual product ID from your Merchant Center account.
  product_id_to_update = "online~en~label~sku123"

  # The ID of the data source that will own the updated product input.
  # Replace with an actual data source ID from your Merchant Center account.
  data_source_id_for_update = "<INSERT_DATA_SOURCE_ID>"

  update_product_input(
      _ACCOUNT_ID, product_id_to_update, data_source_id_for_update
  )

cURL

curl --location --request PATCH 'https://merchantapi.googleapis.com/products/v1/accounts/{ACCOUNT_ID}/productInputs/en~US~SKU12345?updateMask=productAttributes.title,productAttributes.description&dataSource=accounts/{ACCOUNT_ID}/dataSources/{DATASOURCE_ID}' \
--header 'Authorization: Bearer <API_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
   "productAttributes": {
       "title": "A Tale of Two Cities",
       "description": "A classic novel about the French Revolution"
   }
}'

कस्टम एट्रिब्यूट का इस्तेमाल करके अपडेट करना

एक ही कॉल में स्टैंडर्ड और कस्टम एट्रिब्यूट, दोनों को अपडेट किया जा सकता है. किसी कस्टम एट्रिब्यूट को अपडेट करने के लिए, updateMask में उसके नाम से पहले customAttributes जोड़ें.

इस उदाहरण में, एक ही अनुरोध में कई कार्रवाइयाँ की गई हैं:

  • यह स्टैंडर्ड title एट्रिब्यूट को सीधे तौर पर अपडेट करता है.
  • इस तरीके का इस्तेमाल करके, किसी मौजूदा कस्टम एट्रिब्यूट (myCustomAttrToBeUpdated) को अपडेट किया जा सकता है.
  • यह एक नया कस्टम एट्रिब्यूट (myCustomAttrToBeInserted) जोड़ता है.
  • इस तरीके का इस्तेमाल करके, किसी मौजूदा कस्टम एट्रिब्यूट (myCustomAttrToBeDeleted) को मिटाया जा सकता है.
PATCH https://merchantapi.googleapis.com/products/v1/accounts/{ACCOUNT_ID}/productInputs/en~US~SKU12345?updateMask=productAttributes.title,customAttributes.myCustomAttrToBeInserted,customAttributes.myCustomAttrToBeUpdated,customAttributes.myCustomAttrToBeDeleted&dataSource=accounts/{ACCOUNT_ID}/dataSources/{DATASOURCE_ID}
{
  "productAttributes": {
    "title": "ProductTitle Updated"
  },
  "customAttributes": [
    {
      "name": "description",
      "value": "A newly updated description."
    },
    {
      "name": "myCustomAttrToBeUpdated",
      "value": "myCustomAttrToBeUpdated updated value"
    },
    {
      "name": "myCustomAttrToBeInserted",
      "value": "new from update"
    }
  ]
}

अनुरोध पूरा होने पर, अपडेट किया गया ProductInput दिखता है. इसमें सभी बदलाव दिखते हैं.

कस्टम एट्रिब्यूट के अपडेट के बारे में जानकारी

आपने खुद जिन एट्रिब्यूट को तय किया है उन्हें अपडेट करने के लिए, customAttributes फ़ील्ड का इस्तेमाल किया जा सकता है. ये स्टैंडर्ड स्पेसिफ़िकेशन के साथ मैप नहीं होते हैं. इन्हें फ़ाइनल प्रॉडक्ट पर कस्टम एट्रिब्यूट के तौर पर सेव किया जाएगा.

प्रॉडक्ट अपडेट को कैसे प्रोसेस किया जाता है

patch अनुरोध भेजने पर, अपडेट को किसी खास ProductInput डेटा पर लागू किया जाता है. ऐसा, कोई भी नियम लागू होने से पहले किया जाता है. इससे प्रॉडक्ट डालने और अपडेट करने के बीच एक जैसा व्यवहार होता है.

यहां बताया गया है कि आपके अपडेट को कैसे प्रोसेस किया जाता है:

  1. इनपुट अपडेट करना: patch अनुरोध से, आपके दिए गए डेटा सोर्स से जुड़े ProductInput में बदलाव होता है.

  2. प्रोसेस करना और मर्ज करना: इनपुट अपडेट होने के बाद, प्रोसेसिंग शुरू हो जाती है:

    • फ़ीड के नियम और पूरक डेटा सोर्स: प्रॉडक्ट के प्राइमरी सोर्स पर कॉन्फ़िगर किए गए नियम, प्राइमरी और पूरक सोर्स से मिले ProductInput को जोड़ते हैं. इन नियमों से एट्रिब्यूट में बदलाव किया जा सकता है या नए एट्रिब्यूट बनाए जा सकते हैं. नियम सेट अप करने के बारे में ज़्यादा जानने के लिए, https://support.google.com/merchants/answer/14994083 लेख पढ़ें.
    • अन्य डेटा सोर्स: अन्य सोर्स (जैसे, अपने-आप होने वाले सुधार) से मिले डेटा को भी प्राइमरी डेटा सोर्स के इनपुट के साथ मर्ज किया जाता है.
    • पुष्टि करना: मर्ज किए गए डेटा की पुष्टि, प्रॉडक्ट डेटा स्पेसिफ़िकेशन और Google की शॉपिंग नीतियों के हिसाब से की जाती है.
  3. फ़ाइनल प्रॉडक्ट: इस पाइपलाइन का नतीजा, प्रोसेस किया गया फ़ाइनल Product संसाधन होता है. इसे products.get या products.list का इस्तेमाल करके दिखाया जा सकता है. यह प्रॉडक्ट का वह वर्शन है जो Merchant Center में दिखाया जाता है. साथ ही, यह अलग-अलग डेस्टिनेशन पर दिखने की ज़रूरी शर्तें पूरी करता है.

कई चरणों वाली इस प्रोसेस की वजह से, अपडेट का अनुरोध भेजने और Product रिसोर्स में बदलाव दिखने के बीच कुछ मिनटों का समय लगता है. इस रिसोर्स को products.get की मदद से वापस पाया जा सकता है.

उदाहरण: एक प्राइमरी इनपुट का इस्तेमाल करके किसी प्रॉडक्ट को अपडेट करना

यह सबसे ज़्यादा इस्तेमाल किया जाने वाला उदाहरण है. कोई प्रॉडक्ट सिर्फ़ एक प्राइमरी डेटा सोर्स में मौजूद है और आपको उसके कुछ एट्रिब्यूट अपडेट करने हैं.

  1. शुरुआती स्थिति: आपका कोई प्रॉडक्ट en~US~SKU12345, प्राइमरी डेटा सोर्स में title: "Classic T-Shirt" और price: 15.99 USD के साथ मौजूद है.
  2. अपडेट करने का अनुरोध: price को 14.99 USD पर अपडेट करने और availability को out of stock पर सेट करने के लिए, patch का अनुरोध भेजा जाता है.
  3. प्रोसेस किया जा रहा है:
    • SKU12345 के लिए ProductInput की वैल्यू अपडेट की गई है.
  4. फ़ाइनल प्रॉडक्ट: फ़ाइनल Product में अब title: "Classic T-Shirt", price: 14.99 USD, और availability: "out of stock" शामिल हैं.

उदाहरण: पूरक डेटा और नियमों की मदद से किसी प्रॉडक्ट को अपडेट करना

इस उदाहरण में दिखाया गया है कि फ़ीड के नियम, अपडेट पर किस तरह असर डाल सकते हैं. इससे कुछ बदलाव लागू हो जाते हैं, जबकि अन्य बदलावों को अनदेखा कर दिया जाता है.

  1. शुरुआती स्थिति:
    • प्राइमरी इनपुट: en~US~SKU12345 में title: "Great T-Shirt" और description: "A great short-sleeve t-shirt." है.
    • पूरक इनपुट: एक ही प्रॉडक्ट की एंट्री, पूरक डेटा सोर्स में title: "Awesome T-Shirt" और description: "An awesome short-sleeve t-shirt." के साथ मौजूद है.
    • फ़ीड का नियम: title को पूरक डेटा सोर्स से लेने के लिए एक नियम सेट किया गया है. description के लिए कोई नियम नहीं है.
    • नतीजा: प्रोसेस की गई फ़ाइनल Product में title: "Awesome T-Shirt" और description: "A great short-sleeve t-shirt." है.
  2. अपडेट करने का अनुरोध: प्राइमरी डेटा सोर्स को अपडेट करने के लिए, patch अनुरोध भेजा जाता है. इसमें title को "Fantastic T-Shirt" और description को "A fantastic short-sleeve t-shirt." पर सेट किया जाता है.
  3. प्रोसेस किया जा रहा है:
    • प्राइमरी डेटा सोर्स में मौजूद ProductInput को अपडेट करके, title: "Fantastic T-Shirt" और description: "A fantastic short-sleeve t-shirt." कर दिया जाता है.
    • प्रोसेसिंग पाइपलाइन चलती है.
    • title के लिए, फ़ीड के नियम के मुताबिक पूरक डेटा सोर्स (Awesome T-Shirt) से मिली वैल्यू को प्राथमिकता दी जाती है. इसलिए, आपकी अपडेट की गई वैल्यू को अनदेखा कर दिया जाता है.
    • description के लिए, किसी भी नियम को अनदेखा नहीं किया गया है. इसलिए, प्राइमरी इनपुट (A fantastic short-sleeve t-shirt.) से मिली अपडेट की गई वैल्यू का इस्तेमाल किया गया है.
  4. फ़ाइनल प्रॉडक्ट: फ़ाइनल Product का टाइटल अब भी Awesome T-Shirt है (आपका अपडेट लागू नहीं हुआ), लेकिन इसकी जानकारी अब A fantastic short-sleeve t-shirt. है (आपका अपडेट लागू हो गया है).

अपडेट और पूरक डेटा सोर्स में से कोई एक चुनें

productinputs.patch का इस्तेमाल करके या पूरक डेटा सोर्स में डेटा डालकर, प्रॉडक्ट डेटा में बदलाव किया जा सकता है. सबसे सही विकल्प, डेटा मैनेज करने की आपकी रणनीति पर निर्भर करता है.

हमारा सुझाव है कि एक ही प्रॉडक्ट के लिए, एक ही प्रॉडक्ट डेटा को मैनेज करने के लिए, productinputs.patch और पूरक डेटा सोर्स, दोनों का इस्तेमाल न करें. ऐसा करने से, आपको अनुमान के मुताबिक नतीजे नहीं मिलेंगे.

यहां दोनों के बीच तुलना की गई है:

सुविधा productinputs.patch (अपडेट) पूरक डेटा सोर्स
इन स्थितियों में बेहतर है मौजूदा डेटा में तुरंत, बार-बार, और कुछ बदलाव करना. जैसे, कीमत और उपलब्धता. लॉजिक के हिसाब से अलग-अलग डेटा को लेयर करना, अलग-अलग सिस्टम के हिसाब से अलग-अलग एट्रिब्यूट मैनेज करना या नियम के आधार पर जटिल ओवरराइड.
मैकेनिज़्म यह मौजूदा ProductInput में बदलाव करता है. पूरक डेटा सोर्स में एक नया, अलग ProductInput बनाता है.
डेटा के हिसाब से जानकारी का लेवल यह किसी एक ProductInput के कुछ फ़ील्ड पर काम करता है. यह पूरक सोर्स में मौजूद पूरे ProductInput पर काम करता है.
परसिस्टेंस बदलाव तब तक बने रहते हैं, जब तक कि उसी ProductInput को किसी दूसरे patch या पूरे insert से ओवरराइट नहीं किया जाता. फ़ीड के नियमों से यह तय होता है कि किसी प्रॉडक्ट को कितने समय तक दिखाया जाएगा. अगर नियमों में इसे प्राथमिकता दी गई है, तो यह प्राइमरी डेटा को हमेशा के लिए बदल सकता है.
नियमों से इंटरैक्शन इसका इस्तेमाल फ़ीड के नियमों के बिना किया जा सकता है, क्योंकि यह मौजूदा डेटा सोर्स और ProductInput को अपडेट करता है. पूरक सोर्स को लिंक करने के लिए, प्राइमरी सोर्स पर साफ़ तौर पर नियम सेट अप करना ज़रूरी है.
डेटा सोर्स का सेटअप यह मौजूदा डेटा सोर्स पर काम करता है. इसके लिए, किसी नए सोर्स की ज़रूरत नहीं होती. इसके लिए, अलग-अलग पूरक डेटा सोर्स बनाने और मैनेज करने होते हैं. साथ ही, उन्हें फ़ीड के नियमों का इस्तेमाल करके लिंक करना होता है.