Categories
eBay Integration

eBay Integration – Batch Update

Note: The syntax of the Batch Command Language has changed since this post was created. See https://jonrocket.com/ebayintegration/documentation-usage-tabs-tools-tab-batch-update-tool.html

In the past, I’ve found that I often wrote custom PHP code to make changes to many or all of our eBay listings at once. For example, sometimes we wanted a little more time to process orders. In that case, I would run a short PHP script that updated the handling time for each eBay listing.

Now that I am making our eBay Integration for Zen Cart plug-in available to others, I wanted to include a way to make it possible for users to make the same kind of updates without having to write a lot of PHP code.

So, I am including a “Batch Update” tool as a part of the plug-in. It allows you to execute a series of simple, yet powerful, commands to update your eBay listings (and Zen Cart products).

As an example, suppose you added a number of listings to eBay then discovered that one of the Item Specifics you specified was incorrect. You could use the following set of commands to change the values of the “Brand” in the Item Specifics to “Company Name” in every listing where it is misspelled as “Copany Name”:

WHERE ebay.itemspecifics INCLUDES 'Brand|Copany Name'
REMOVE 'Brand|Copany Name' FROM ebay.itemspecifics
ADD 'Brand|Company Name' TO ebay.itemspecifics

The WHERE command defines the initial working set. The working set is the collection of products that the following commands will operate on. Only products matching the expression in the WHERE command will be included in the working set.

In the above example, only products associated with eBay listings that have an Item Specific defined as ‘Brand’ => ‘Copany Name’ will be included in the working set.

If you wanted all products to be included in the working set, you could enter:

WHERE true

To include only products with associated eBay Listings, you could enter:

WHERE ebay.itemid NOT IS ''

All expressions in the batch language consist of a single operand or two operands around an operator. So, if you want to create a working set based on more than one attribute, you need to use multiple commands. For example, to create a working set of products listed on eBay with the word ‘Toy’ in there title, you could use:

WHERE ebay.itemid NOT IS ''
AND ebay.title CONTAINS 'Toy'

The AND command modifies the working set by removing any products that do not match the expression.

To add products to the working set, use the OR command:

WHERE false
OR true

The above example is a rather odd way of adding all products to the working set. The OR command adds all products matching the expression to the working set.

Expressions are always evaluated in the context of a product – once for every product. For example, you can define a variable with the SET command:

SET $title = ebay.title

You can display the value of the variable using the EVAL command:

WHERE true
SET $title = ebay.title
EVAL $title

The EVAL command will list the value for each product.

You can also use the SET command to change the value of an eBay listing attribute (or store attribute). For example:

WHERE ebay.title ENDS WITH ' Toy'
SET $title = ebay.title
SET ebay.title = ebay.title TRIM END ' Toy'
SET ebay.title = ebay.title APPEND ' Chew Toy'
EVAL $title
EVAL ebay.title

The above will change every eBay title that ends with ‘ Toy’ to a title that ends with ‘ Chew Toy.’ The $title variable will contain the original title and won’t be changed when the title is updated.

Unless you check the “Commit?” box before submitting the batch script, the script will not actually change any listings at eBay. This allows you to test a script without changing any of your listings. Once you are satisfied that the script works as intended, you can check the “Commit?” box then submit the form and the changes will actually be made.