MerchelloContext
Documentation for the MerchelloContext
The MerchelloContext is a singleton instantiated during the application startup.
In some ways the MerchelloContext is analogous to Umbraco's ApplicationContext but with respect to the Merchello package.
It provides access to Merchello Services, Gateways and Cache.
MerchelloContext.Current.Cache
Merchello's cache is Umbraco's cache: `ApplicationContext.Current.ApplicationCache'. The association is stored within the MerchelloContext mainly for control during testing.
static Current property.var merchelloContext = MerchelloContext.Current;
var services = MerchelloContext.Current.Services;
// example for the customer service
var customerService = MerchelloContext.Current.Services.CustomerService;
ServiceContext Properties
| Name | |
|---|---|
| AuditLogService | The AuditLogService is intended to be used to log Merchello related informational records that would not otherwise be normally recorded in an application's generic logging system. |
| CustomerService | The CustomerService is used to manage Merchello customers |
| EntityCollectionService | This service is used to manage entity collections. Both Static and Dynamic Collections are managed with the EntityCollectionService . |
| GatewayProviderService | The GatewayProviderService allows you to get to the gateways in Merchello. Gateways. |
| InvoiceService | The InvoiceService allows you to manage invoices. |
| ItemCacheService | The ItemCacheService is used to manage ItemCache collections such as those in the Basket , Wishlist and SalePreparation objects. |
| OrderService | The OrderService manages items that need to be shipped and fulfilled from a warehouse. |
| PaymentService | The PaymentService is used manage payments. |
| StoreSettingService | The StoreSettingService manage global store settings, currency, currency formats, country and regional settings. |
| ProductService | The ProductService is used to manage products in the back office product catalog. |
| ShipmentService | The ShipmentService is used to manage shipments in Merch. |
GatewayContext
var gatewayContext = MerchelloContext.Current.Gateways;
NotificationContext
The
NotificationContextis responsible for passing notification message to any NotificationGatewayProviders configured in the back office.
var notificationContext = MerchelloContext.Current.Gateways.Notification;
Methods
| GetNotificationMessagesByMonitorKey(Guid monitorKey) | Gets a collection of INotificationMessage s by a Monitor Key (Guid) |
| Send(INotificationMessage message) | Sends a INotificationMessage |
| Send(INotificationMessage message, IFormatter formatter); | Sends a INotificationMessage with a designated formatter |
PaymentContext
The
PaymentContentis responsible for managing payment methods across multiple PaymentGatewayProvider(s) configured in the back office.
var paymentContext = MerchelloContext.Current.Gateways.Payment;
Methods
| Name | Description |
|---|---|
| GetPaymentGatewayMethods() | Gets a list of all possible Payment Methods |
| GetPaymentGatewayMethodByKey(Guid paymentMethodKey) | Gets a IPaymentGatewayMethod by its unique key |
ShippingContext
The
ShippingContextis responsible for getting shipment (freight) rate quotes across all qualifying ShippingGatewayProvider methods for a given shipping destination - determined by shipping destination country.
var shippingContext = MerchelloContext.Current.Gateways.Shipping;
Methods
| GetShipRateQuotesForShipment(IShipment shipment, bool tryGetCached = true) | Returns a collection of all IShipmentRateQuote that are available for the IShipment |
| GetAllowedShipmentDestinationCountries() | Returns a list of all countries that can be assigned to a shipment |
| GetGatewayProvidersByShipCountry(IShipCountry shipCountry) | Gets a collection of ShippingGatewayProviders for a particular ship country |
TaxationContext
The
TaxationContextis responsible for providing taxation calculation for either an invoice or product based taxation.
var taxationContext = MerchelloContext.Current.Gateways.Taxation;
Properties
| ProductPricingEnabled | Returns a value indicating whether the product based tax pricing is enabled. (Set in the back office) |
| TaxationApplication | Returns an enum value - Invoice or Product |
Methods
| CalculateTaxesForInvoice(IInvoice invoice, bool quoteOnly = false) | Calculates taxes for an invoice. |
| CalculateTaxesForInvoice(IInvoice invoice, IAddress taxAddress, bool quoteOnly = false) | Calculates taxes for an invoice. |
| CalculateTaxesForProduct(IProductVariantDataModifierData product) | Calculate taxes for a product when product based taxation is enabled. |
| GetTaxMethodForTaxAddress(IAddress taxAddress) | Gets the tax method for a given tax address |
| GetTaxMethodForCountryCode(string countryCode) | Gets the tax method for country code. |
Updated less than a minute ago
