Class ProductInitializer
java.lang.Object
com.softslate.commerce.customer.product.ProductInitializer
Initializes singleton objects related to products, in the application scope.
Called by
BaseRequestProcessor
at the beginning of a request, if the singletons are found to be
missing.- Author:
- David Tobey
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.apache.struts.action.ActionServlet
void
initializeBuiltInCategories
(BusinessObjectFactory businessObjectFactory) Creates aCollection
containing each of the built-in categories in the system.void
initializeCategoryTree
(BusinessObjectFactory businessObjectFactory) Creates aCollection
representing the tree of categories in the system.void
initializeManufacturers
(BusinessObjectFactory businessObjectFactory) Creates aCollection
containing each of the manufacturers in the system.void
initializeStoreDiscounts
(BusinessObjectFactory businessObjectFactory) Creates aCollection
containing discounts for display within the store.void
setServlet
(org.apache.struts.action.ActionServlet servlet)
-
Field Details
-
log
static org.apache.commons.logging.Log log -
servlet
private org.apache.struts.action.ActionServlet servlet
-
-
Constructor Details
-
ProductInitializer
public ProductInitializer() -
ProductInitializer
public ProductInitializer(org.apache.struts.action.ActionServlet servlet)
-
-
Method Details
-
getServlet
public org.apache.struts.action.ActionServlet getServlet() -
setServlet
public void setServlet(org.apache.struts.action.ActionServlet servlet) -
initializeCategoryTree
Creates aCollection
representing the tree of categories in the system. Places theCollection
in the application scope as an attribute with the name "categoryTree" so it can be referenced on any store screen. (Useapplication.categoryTree
to reference theCollection
from within a JSP template.) Each item in theCollection
is an instance ofCategory
, which corresponds to each one of the "top level" categories defined in the store (i.e., categories whoseparentCategory
property isnull
). To render the tree, iterate through the top level categories and recursively navigate through each of theirsubcategoryCollection
s in turn.This method invokes
ProductProcessor.loadCategoryTree()
to load the category information from the database.- Parameters:
businessObjectFactory
- An initializedBusinessObjectFactory
used to create theProductProcessor
implementer that loads the category information from the database.
-
initializeBuiltInCategories
Creates aCollection
containing each of the built-in categories in the system. Built-in categories are typically composed of specials or other featured products that need to displayed on arbitrary pages thoughout the store. This method places theCollection
in the application scope as an attribute with the name "builtInCategories" so it can be referenced on any store screen. Each item in theCollection
is an instance ofCategory
. (Useapplication.builtInCategories
to reference theCollection
from within a JSP template.)Built-in categories are definined by the "builtInCategories" setting in the
sscSetting
database table, a comma-separated list of category codes.This method invokes
ProductProcessor.loadBuiltInCategories()
to load the category information from the database.- Parameters:
businessObjectFactory
- An initializedBusinessObjectFactory
used to create theProductProcessor
implementer that loads the category information from the database.
-
initializeManufacturers
Creates aCollection
containing each of the manufacturers in the system. This method places theCollection
in the application scope as an attribute with the name "manufacturers" so it can be referenced on any store screen. Each item in theCollection
is an instance ofManufacturer
. (Useapplication.manufacturers
to reference theCollection
from within a JSP template.)This method invokes
ManufacturerProcessor.loadActiveManufacturers()
to load the manufacturers' information from the database.- Parameters:
businessObjectFactory
- An initializedBusinessObjectFactory
used to create theManufacturerProcessor
implementer that loads the manufacturers' information from the database.
-
initializeStoreDiscounts
Creates aCollection
containing discounts for display within the store. The discounts include any global discount (which apply to the user's cart as a whole rather than to particular line items), or discounts where a condition of the discount is that a given product is in the user's cart (querying for these discounts here allows us to display them alongside the required products, as a method of upselling). This method places theCollection
in the application scope as an attribute with the name "storeDiscounts" so it can be referenced on any store screen. Each item in theCollection
is an instance ofDiscount
. (Useapplication.storeDiscounts
to reference theCollection
from within a JSP template.)This method invokes
DiscountProcessor.loadStoreDiscounts()
to load the discounts' information from the database.- Parameters:
businessObjectFactory
- An initializedBusinessObjectFactory
used to create theDiscountProcessor
implementer that loads the discounts' information from the database.
-