public class RelatedProductsHandler extends DBUHandler
BOBW 02/25/2021 - A new sort code field has been added to the product group x-ref database table and to the delimited import file. In order to accommodate sites that have not had this new field added to the table, the code has been written to allow for the field to be missing.
| Modifier and Type | Class and Description |
|---|---|
class |
RelatedProductsHandler.Relationship
Inner class that defines a related product relationship.
|
| Modifier and Type | Field and Description |
|---|---|
private static int |
cvPgxNumFlds
The number of fields in the product group x-ref database table.
|
private Product |
ivProduct
The current product being processed.
|
protected static boolean |
RELATED_ICON
A flag indicating whether to show the related items icon on the catalog
grid and list pages as well as the review cart and favorite items pages,
as defined by "Product.Catalog.Show.RelatedItemsIcon".
|
protected static java.lang.String[] |
RELATED_TYPE
An array of relationship type codes to include when determining if the
related items icon should be displayed, as defined in properties by
"Product.Catalog.Show.RelatedItemsType".
|
private static long |
serialVersionUID
The class' serialization version id.
|
ivContext| Constructor and Description |
|---|
RelatedProductsHandler()
Constructs a new instance of the related products handler with a
null servlet or thread context. |
| Modifier and Type | Method and Description |
|---|---|
private java.lang.String |
columnToString(java.sql.ResultSet rs,
java.lang.String colname)
Returns a
String object from the given result set of database
records for the specified column index. |
java.util.ArrayList<RelatedProductsHandler.Relationship> |
getRelatedProducts(Product product)
Retrieves and returns a product's related products.
|
java.util.ArrayList<RelatedProductsHandler.Relationship> |
getRelatedProductsForIcon(Product product)
Retrieves and returns a product's related products for the purpose of
displaying the related items icon on the catalog grid and list pages as
well as the review cart and favorite items pages.
|
private java.util.ArrayList<RelatedProductsHandler.Relationship> |
getRelationships(java.lang.String grpcode)
Retrieves the relationships for a group and/or product/uom.
|
void |
omitNoStockProducts(java.util.ArrayList<RelatedProductsHandler.Relationship> related)
Removes products with no stock from .
|
private java.util.ArrayList<RelatedProductsHandler.Relationship> |
processResultSet(java.sql.ResultSet rs)
Processes the result set from the query of "getRelationships".
|
void |
setRealtimeInfo(java.util.ArrayList<RelatedProductsHandler.Relationship> related)
Sets the realtime information (current price, availability, etc.) for a
set of related product relationships.
|
getContext, setContextprivate static final long serialVersionUID
protected static final boolean RELATED_ICON
protected static final java.lang.String[] RELATED_TYPE
private static int cvPgxNumFlds
private Product ivProduct
public RelatedProductsHandler()
null servlet or thread context.
A CONTEXT MUST BE SET BEFORE INVOKING ANY OTHER METHODS.
.public java.util.ArrayList<RelatedProductsHandler.Relationship> getRelatedProducts(Product product)
product - (Product) The product for the desired related products.public java.util.ArrayList<RelatedProductsHandler.Relationship> getRelatedProductsForIcon(Product product)
product - (Product) The product for the desired related products.public void omitNoStockProducts(java.util.ArrayList<RelatedProductsHandler.Relationship> related)
related - (ArrayList) The related product relationships to process.public void setRealtimeInfo(java.util.ArrayList<RelatedProductsHandler.Relationship> related)
related - (ArrayList) The related product relationships to process.private java.util.ArrayList<RelatedProductsHandler.Relationship> getRelationships(java.lang.String grpcode)
grpcode - (String) The product group code for the desired
relationships.private java.util.ArrayList<RelatedProductsHandler.Relationship> processResultSet(java.sql.ResultSet rs) throws java.lang.Exception
rs - (ResultSet) The result of the query.java.lang.Exception - - if an error occurs while accessing the
result set.private java.lang.String columnToString(java.sql.ResultSet rs,
java.lang.String colname)
throws java.sql.SQLException
String object from the given result set of database
records for the specified column index.rs - (ResultSet) The result set containing the database record
from which a column's string value is to be retrieved.colname - (String) The name of the column from which a string
is to be retrieved and returned.String. A
null column value is returned as an empty string.java.sql.SQLException - if an error occurs while processing the
result set.