@ConsumerType
public interface CommerceService
CommerceService
is the root of the Commerce API; other classes are fetched
through it.
In the case of external commerce providers, the CommerceService handles basic connectivity to the commerce server, including command translation and issuance to the server's service API.
Individual resources in the repository can nominate a particular implementation of the
CommerceService
through their CommerceConstants.PN_COMMERCE_PROVIDER
properties.
A CommerceService
is then normally fetched using the adapter pattern:
resource.adaptTo(CommerceService.class)
Modifier and Type | Method and Description |
---|---|
void |
catalogRolloutHook(Page blueprint,
Page catalog)
Called during catalog creation or update to allow the commerce implementation to perform
implementation-specific actions.
|
java.util.List<Promotion> |
getAvailablePromotions(ResourceResolver resourceResolver)
Get the list of available promotions.
|
java.util.Map<java.lang.String,java.lang.Object> |
getContext()
Get the context or an empty map if no context has been set before via
setContext(Map) . |
java.util.List<java.lang.String> |
getCountries()
Deprecated.
since 6.1, use
CommerceSession.getAvailableCountries() |
java.util.List<java.lang.String> |
getCreditCardTypes()
Deprecated.
since 6.1, use
CommerceSession.getAvailablePaymentMethods() |
java.util.List<java.lang.String> |
getOrderPredicates()
Get the list of predicates for selecting placed orders.
|
Product |
getProduct(java.lang.String path)
Get the product by path.
|
ProductCollection |
getProductCollection(java.lang.String path)
Get the product collection by path (or ID for external product collections).
|
Promotion |
getPromotion(java.lang.String path)
Get the voucher by path (or ID for external promotions).
|
java.lang.String |
getServer()
Get the configured commerce server endpoint.
|
Voucher |
getVoucher(java.lang.String path)
Get the voucher by path (or ID for external vouchers).
|
boolean |
isActivated(Product product)
Check for public availability of a product.
|
boolean |
isAvailable(java.lang.String serviceType)
Test whether the commerce service (especially ones that rely on 3rd party services) is
currently available.
|
CommerceSession |
login(SlingHttpServletRequest request,
SlingHttpServletResponse response)
Returns a
CommerceSession for the user identified by the given request. |
void |
productRolloutHook(Product productData,
Page productPage,
Product productReference)
Called during catalog creation or update to allow the commerce implementation to perform
implementation-specific actions.
|
CommerceResult |
search(CommerceQuery query)
Perform a search.
|
void |
sectionRolloutHook(Page blueprint,
Page section)
Called during catalog creation or update to allow the commerce implementation to perform
implementation-specific actions.
|
void |
setContext(java.util.Map<java.lang.String,java.lang.Object> context)
Set a context for this service instance and any session retrieved from it.
|
CommerceSession login(SlingHttpServletRequest request, SlingHttpServletResponse response) throws CommerceException
CommerceSession
for the user identified by the given request.request
- The scope's request.response
- The scope's response.CommerceSession
for the user.CommerceException
boolean isAvailable(java.lang.String serviceType)
serviceType
- The type of the service that is tested to be available (e.g. payment,
fulfillment etc.).CommerceConstants.SERVICE_COMMERCE
java.lang.String getServer()
void setContext(java.util.Map<java.lang.String,java.lang.Object> context)
Note that the context is not persisted across requests and needs to be set again when creating a new service instance.
context
- java.util.Map<java.lang.String,java.lang.Object> getContext()
setContext(Map)
.Product getProduct(java.lang.String path) throws CommerceException
path
- null
if the path doesn't represent a product.CommerceException
Promotion getPromotion(java.lang.String path) throws CommerceException
path
- null
if not found.CommerceException
Voucher getVoucher(java.lang.String path) throws CommerceException
path
- null
if not found.CommerceException
ProductCollection getProductCollection(java.lang.String path) throws CommerceException
path
- null
if not found.CommerceException
boolean isActivated(Product product) throws CommerceException
product
- CommerceException
void catalogRolloutHook(Page blueprint, Page catalog) throws CommerceException
The catalogRolloutHook
is called after the root catalog page is created
or updated.
Note: if changes are made, the appropriate lastModified dates should be updated.
blueprint
- The catalog blueprint.catalog
- The catalog page created from the blueprint.CommerceException
void sectionRolloutHook(Page blueprint, Page section) throws CommerceException
The sectionRolloutHook
is called after each section page is created or
updated.
Note: if changes are made, the appropriate lastModified dates should be updated.
blueprint
- The catalog section blueprint.section
- The section page created from the blueprint.CommerceException
void productRolloutHook(Product productData, Page productPage, Product productReference) throws CommerceException
The productRolloutHook
is called after each product page is created or
updated.
Note: if changes are made, the appropriate lastModified dates should be updated.
productData
- The productData for which the product page was created.productPage
- The product page created from the section blueprint's product template.productReference
- The product reference on the created/updated page.CommerceException
CommerceResult search(CommerceQuery query) throws CommerceException
query
- The query representing the search parametersCommerceResult
representing the search resultsCommerceException
java.util.List<Promotion> getAvailablePromotions(ResourceResolver resourceResolver) throws CommerceException
resourceResolver
- a Sling ResourceResolver instanceList<Promotion>
containing the promotions.CommerceException
java.util.List<java.lang.String> getOrderPredicates() throws CommerceException
List
of order predicate names.CommerceException
@Deprecated java.util.List<java.lang.String> getCountries() throws CommerceException
CommerceSession.getAvailableCountries()
List
containing ISO-country-code values.CommerceException
@Deprecated java.util.List<java.lang.String> getCreditCardTypes() throws CommerceException
CommerceSession.getAvailablePaymentMethods()
List
containing credit-card types.CommerceException
Copyright © 2010 - 2020 Adobe. All Rights Reserved