Working with Availabilities
For availabilities there is a similar concepts like the PriceSystems for prices - which is called Availability Systems.
The Availability Systems are responsible for retrieving or calculating availabilities of a product and returning a so called
AvailabilityInfo object which contains all the availability information.
Each product can have its own Availability System.
Configuration of Availability Systems
A availability system is a class implementing
is defined as service and registered with a name in the
pimcore_ecommerce_framework.availability_systems configuration tree.
Currently the framework ships only with a sample implementation which you can use as starting point.
There are 3 places where the configuration of Availability Systems takes place:
- Product class: Each product has to implement the method
getAvailabilitySystemName()which returns the name of its Availability System.
- Service definition: Each Availability System must be registered as service
- Configuration: The
availability_systemssection maps Availability System names to service IDs
The product class returns the name of an Availability System:
class MyProduct implements \Pimcore\Bundle\EcommerceFrameworkBundle\Model\CheckoutableInterface
public function getAvailabilitySystemName(): string
Each Availability System must be defined as service (either a service defined by core configuration or your custom services):
# AVAILABILITY SYSTEMS
availability_systems configuration maps names to service IDs:
# defines 3 availability systems
# the availability system is already defined in core availability_systems.yaml service definition
Each product (if it implements
CheckoutableInterface) needs to implement the method
getOSAvailabilityInfo which in the default
implementation gets the corresponding Availability System and calculates the availability.
The return value is an
AvailabilityInterface object, which at least has one
getAvailable method and can contain additional
availability information (e.g. availability for different storage locations etc.).
This can be used to visualize availability on product detail pages or to check, if a product can actually be checked out.