Class: FlexCommerce::Category

Inherits:
FlexCommerceApi::ApiBase show all
Defined in:
app/models/category.rb

Overview

A flex commerce Category model

This model provides access to the flex commerce categories and associated products. As managing the categories is the job of the administration panel, this model is read only.

It is used much like an active record model.

Examples:

# Fetching all categories

FlexCommerce::Category.all #fetches all categories(actually the first page in case there are thousands)

# Pagination

FlexCommerce::Category.paginate(page:2).all # Fetches page 2 of categories.
The page size is predefined on the server side

# Finding categories

FlexCommerce::Product.find("my-category-slug") # Finds the category with this unique id

# Finding nested categories of the category

FlexCommerce::Category.find("my-category-slug").categories

# Finding products within the categories

FlexCommerce::Category.find("my-category-slug").products

or if you already know the category id - then

@TODO Look into this

Constant Summary

Constants inherited from FlexCommerceApi::BaseResource

FlexCommerceApi::BaseResource::PRIVATE_ATTRIBUTES, FlexCommerceApi::BaseResource::RELATED_META_RESOURCES

Instance Method Summary collapse

Methods inherited from FlexCommerceApi::ApiBase

endpoint_version

Methods inherited from FlexCommerceApi::BaseResource

all, append_version, #as_json_api, capture_surrogate_keys, create!, endpoint_version, find, find_all, #freeze, #initialize, load, #meta_attribute, #method_missing, paginate, password, path, #public_attributes, reconfigure, reconfigure_all, reconfigure_api_base, reload_connection_if_required, #save!, username

Constructor Details

This class inherits a constructor from FlexCommerceApi::BaseResource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class FlexCommerceApi::BaseResource

Instance Method Details

#allFlexCommerce::Category[]

Returns all categories

Returns:



# File 'app/models/category.rb', line 48

#categoriesFlexCommerce::Category[]

Provides a list of associated sub categories

Returns:



# File 'app/models/category.rb', line 57

#findFlexCommerce::Category

Finds a category

Parameters:

  • spec (String)

Returns:

Raises:



# File 'app/models/category.rb', line 42

#paginateObject

Paginates the list of categories by a preset page size

Parameters:

  • options (Hash)

    The options to paginate with

  • options (Numeric|String)

    :page The page to fetch



# File 'app/models/category.rb', line 52