filters the array of loading options passed to the load method of the Collection object

add_filter( 'shopp_{slug}_collection_load_options', [callback] )

@param array $load_options array of loading options passed to the load method of the Collection object


filters the array of loading options passed to the load method of the Collection object

Load Options

  • columns: string (Default: false) Include extra columns. ie. ‘c.col1,c.col2…’
  • useindex: string (Default: false) FORCE INDEX to be used on the product table. ie. ‘indexname’
  • joins: array (Default: array()) array of JOIN tables. ie. array(‘INNER JOIN table AS t ON’)
  • where: array (Default: array()) array of AND joined WHERE query conditions. ie. array(‘x=y OR x=z’,’a!=b’…)
  • groupby: string (Default: false) GROUP BY column. ie. ‘column’
  • orderby: string (Default: false) ORDER BY columns. ie. ‘p.post_title ASC’ or ‘p.post_title DESC’ (string)
  • having: array (Default: array()) AND joined HAVING filters.
  • limit: int (Default: false) number of products to which the results should be limited.
  • order: string (Default: false) ORDER BY columns or named methods. Used instead of orderby. ie. ‘bestselling’,’highprice’,’lowprice’,’newest’,’oldest’,’random’,’chaos’,’title’
  • page: (Default: false) Current page number to load
  • paged: (Default: false) Entries per page to load
  • nostock: (Default: true) Override to show products that are out of stock (string) ‘on’,’off’,’yes’,’no’…
  • pagination: string (Default: true) Enable alpha pagination. ie. ‘alpha’ for alphabetic pagination, ‘true’ for numeric pagination
  • published: string (Default: true) Load published or unpublished products. ie. ‘on’,’off’,’yes’,’no’…
  • ids: bool (Default: false) Flag for loading product IDs only
  • load: array (Default: array()) array of supplementary product data to load for each product in the collection. ie. array(‘summary’,’prices’,’specs’,’meta’,’images’,’coverimages’,’categories’,’tags’)
  • debug: debug (Default: false) Causes the query to be echoed, for debugging purposes.

Collection Slugs

The default set of collection slugs are as follows (additional collections can be registered):

  • catalog: all catalog products collection
  • new: new products collection
  • featured: featured products collection
  • onsale: on sale products collection
  • bestsellers: best selling products collection
  • search-results: product search results collection
  • tag: tag products collection
  • related: related products collection
  • alsobought: the also bought products collection
  • random: random products collection
  • viewed: viewed products collection
  • promo: promotion related products collection


// filters in the form of shopp_$slug_collection_load_options
$slugs = array(

foreach ( $slugs as $slug ) {
    add_filter("shopp_$slug_collection_load_options", 'collection_load_options_filter');

function collection_load_options_filter ( $load_options ) {
    // do stuff
    return $load_options;

// filter featured products collection load options
add_filter('shopp_featured_collection_load_options', 'load_options_for_featured_collection');

function load_options_for_featured_collection ( $load_options ) {
    // load only unpublished products
    $load_options['published'] = 'off';
    return $load_options;
// filter catalog products collection load options
add_filter('shopp_catalog_collection_load_options', 'load_options_for_catalog_collection');

function load_options_for_catalog_collection ( $load_options ) {
    $added_options = array( 
        'load' => array(), // empty to force all product data to load

    return array_merge( $load_options, $added_options );
// filter new products collection load options
add_filter('shopp_new_collection_load_options', 'load_options_for_new_collection');

function load_options_for_new_collection ( $load_options ) {
    $added_options = array(
        'ids' => true,      // only populate the product IDs

    return array_merge( $load_options, $added_options );

See Also

  1. There is also a “taxquery” option available which is undocumented, it is extremely useful as it works similarly to WP’s “tax_query”.

    $load_options['taxquery']['relation'] = 'OR';
    $load_options['taxquery'][] = array(
        'taxonomy'  => 'shopp_category',
        'field' => 'slug',
        'terms' => array('uncategorized')

    It is important to remember that there is no underscore in the option key.

    August 20th   #

  2. Further to wbickley’s revelation, here’s an example query for tags:

    $load_options['taxquery'][] = array(
        'taxonomy'  => 'shopp_tag',
        'field' => 'slug',
        'terms' => array('rhubarbish','cheesy'),
        'operator'  => 'NOT IN'

    In this example only item’s that are NOT tagged with ‘rhubarbish’ or ‘cheesy’ will be returned.

    June 17th   #

You must be logged in to post a comment.

© Ingenesis Limited. Shopp™ is a registered trademark of Ingenesis Limited.