Help

Frequently asked questions and other useful tidbits.

Product Class

Updated on April 25th, 2008

Each of these methods (except where noted) supports a custom callback function. You can also supply different Ajax options for even more control.

find(permalink, callback, options)

Returns a product based on the given permalink.

Product.find('my-tee', function(product) {
  alert("I found " + product.name + "!");
});

findAll(params, callback, options)

Returns an array of all products. You can refine the result by passing params: limit (default set on the Design > Theme page of the admin), page (used for pagination, 1 by default), artist (permalink of an artist), and category (permalink of a category).

Product.findAll({}, function(products) {
  alert("I found " + products.length + " products!");
});
 
Product.findAll({ category: 'tees' }, function(products) {
  alert("I found " + products.length + " tees!");
});

search(term, params, callback, options)

Returns an array of all products that match the specified search term. Most of the params from findAll will work as well.

Product.search('shirt', {}, function(products) {
  alert("I found " + products.length + " products!");
});
 
Product.search('shirt', { limit: 5 }, function(products) {
  alert("I found " + products.length + " tees!");
});

findImage(url, size)

Returns the URL of an image with the given size. Works just like the product_image_url filter.

Product.findImage(product.image, 'thumb');

Contact

Can’t find an answer to your question? No worries, we’re here to help.