Skip to main content
Published: March 17 2011, 4:26:00 PMUpdated: November 28 2020, 1:54:02 PM

Use the ReviseFixedPriceItem call to change the properties of a currently active fixed-price listing.

Here is a Java ReviseFixedPriceItem sample for revising a multi-variation item (adding and deleting a variation).

/*
© 2011-2013 eBay Inc., All Rights Reserved
Licensed under CDDL 1.0 - http://opensource.org/licenses/cddl1.php
*/


import com.ebay.sdk.*;
import com.ebay.sdk.call.*;
import com.ebay.soap.eBLBaseComponents.*;

/**
*
*
* The following steps need to be done to delete a field from an existing listing.
*
* 1. Create an ApiContext Object
* 2. Set the auth token and target api url (Webservice endpoint)
* 3. Create a ReviseFixedPriceItemCall object.
* 4. Create an item object and set the SKU for the item.
* 5. Create a VariationType for each variation that is to be listed.
* 6. Add item specifics for each variation (Refer ReviseItem specifics samples)
* 7. Set all the variations to VariationsType object and set this to the item using ItemType#setVariations(VariationsType)
* 8. Set the item as the itemToBeRevised in the ReviseItemCall object.
* 9. Invoke ReviseItemCall#reviseItem() to execute the revision.
*
*/
public class ReviseFixedPriceItemVariation {

    public static void reviseMultiVariationItem() {
        ApiContext apiContext = new ApiContext();
        ApiCredential cred = apiContext.getApiCredential();
        ApiLogging apiLogging = new ApiLogging();
        apiContext.setApiLogging(apiLogging);
       
        // set the server url and credentials for Sandbox
        apiContext.setApiServerUrl("https://api.sandbox.ebay.com/wsapi");
        cred.seteBayToken("YourToken");

        // Set site to US
        apiContext.setSite(SiteCodeType.US); 

        ReviseFixedPriceItemCall reviseFP = new ReviseFixedPriceItemCall(apiContext);
        ItemType item = new ItemType();
        item.setSKU("CODE_SAMPLE_FPMVAR_SKU1");

        // Adding a new variation Blue - M  
        VariationType variation1 = new VariationType();
        variation1.setSKU("CODE_SAMPLE_FPMVAR_SKU1_LBLUE");

        // Create variation specifics
        NameValueListType sizeVariation = new NameValueListType();
        sizeVariation.setName("Size");
        sizeVariation.setValue(new String[]{"M"});

        NameValueListType colorVariation = new NameValueListType();
        colorVariation.setName("Color");
        colorVariation.setValue(new String[]{"Blue"});

        NameValueListArrayType nvListArray = new NameValueListArrayType();
        nvListArray.setNameValueList(new NameValueListType[]{sizeVariation, colorVariation});

        // add variation specifics to a variation object
        variation1.setVariationSpecifics(nvListArray);

        AmountType amt = new AmountType();
        amt.setCurrencyID(CurrencyCodeType.USD);
        amt.setValue(12.00);

        variation1.setStartPrice(amt);
        variation1.setQuantity(10);

        // Adding a new variation Blue - L
        VariationType variation2 = new VariationType();
        variation2.setSKU("CODE_SAMPLE_FPMVAR_SKU1_LBLUE");

        // Create variation specifics
        NameValueListType sizeVariation2 = new NameValueListType();
        sizeVariation2.setName("Size");
        sizeVariation2.setValue(new String[]{"L"});

        NameValueListType colorVariation2 = new NameValueListType();
        colorVariation2.setName("Color");
        colorVariation2.setValue(new String[]{"Blue"});

        NameValueListArrayType nvListArray2 = new NameValueListArrayType();
        nvListArray2.setNameValueList(new NameValueListType[]{sizeVariation2, colorVariation2});
           
          // add variation specifics to a variation object
          variation2.setVariationSpecifics(nvListArray2);

          AmountType amt2 = new AmountType();
          amt2.setCurrencyID(CurrencyCodeType.GBP);
          amt2.setValue(12.00);
           
          variation2.setStartPrice(amt);           
          variation2.setQuantity(10);           
           
          // Delete an existing variation Brown - M
          VariationType variation3 = new VariationType();
          variation3.setSKU("CODE_SAMPLE_FPMVAR_SKU1_MBROWN");
          variation3.setDelete(true);
           
          VariationsType variations  = new VariationsType();
          // add individual variations to a variations object
          variations.setVariation(new VariationType[]{variation1,variation2,variation3});
           
          item.setVariations(variations);
           
          reviseFP.setItemToBeRevised(item);
           
          try {
               reviseFP.reviseFixedPriceItem();
          } catch (ApiException e) {
               e.printStackTrace();
          } catch (SdkException e) {
               e.printStackTrace();
          } catch (Exception e) {
               e.printStackTrace();
          }
                     
     }
      
     public static void main(String[] args) {
          reviseMultiVariationItem();
     }

}

 

How well did this answer your question?
Answers others found helpful