Logidav Docs

SaleProductAvailabilityService extends TransactionalService
in package

Class SaleProductAvailabilityService

Service to determine product availability and delivery information for sale products. Handles the logic where "dispo" (availability) can be either:

  • The product's availability date
  • The container's arrival date (when a container is assigned to the product)

Supports multi-language translation based on store ID locale mapping.

Table of Contents

Properties

$em  : EntityManager
$storeToLocale  : array<string|int, mixed>
$translator  : TranslatorInterface

Methods

addRepository()  : void
Add a repository to this service
addService()  : void
Add a service to this service
getCalculatedAvailability()  : array<string|int, mixed>
Get availability bracket (similar to Product::getCalculatedDispo)
getContainerInfo()  : array<string|int, mixed>|null
Get container information if available
getDeliveryInfo()  : string
Calculate delivery date information Similar to Magento's getMenzzoIndexLimitShippingDay method
getEntityManager()  : EntityManager
Getter of the Entity Manager
getOrderDeliveryInfo()  : string
Get delivery information for a sale product Similar to Magento's getOrderDeliveryInfo method
getProductDispo()  : string|null
Get the availability date (dispo) for a sale product
isInStock()  : bool
Check if a sale product is in stock based on availability date
setEntityManager()  : mixed
Setter of the Entity Manager
setStoreToLocale()  : mixed
Set the store to locale mapping
setTranslator()  : mixed
Set the translator
getLanguageCode()  : string
Convert full locale to language code for translator Converts 'fr_FR' to 'fr', 'de_DE' to 'de', etc.
getLocaleForStore()  : string
Get the locale for a given store ID
getMonthName()  : string
Get the translated month name
normalizeAvailabilityValue()  : string|null
Normalize a raw availability value returned by SaleProduct.

Properties

Methods

addRepository()

Add a repository to this service

public addRepository(int $key, string $class) : void
Parameters
$key : int

Key

$class : string

Class

addService()

Add a service to this service

public addService(int $key, mixed $service) : void
Parameters
$key : int

Key

$service : mixed

getCalculatedAvailability()

Get availability bracket (similar to Product::getCalculatedDispo)

public getCalculatedAvailability(SaleProduct $saleProduct[, bool $translate = false ]) : array<string|int, mixed>
Parameters
$saleProduct : SaleProduct
$translate : bool = false

Whether to translate the availability text (default: false for backward compatibility)

Return values
array<string|int, mixed>

Array with 'dispo' (raw value) and 'date' (bracket like 'En_Stock', '1_semaines', etc.)

getContainerInfo()

Get container information if available

public getContainerInfo(SaleProduct $saleProduct) : array<string|int, mixed>|null
Parameters
$saleProduct : SaleProduct
Return values
array<string|int, mixed>|null

Array with container details or null if no container

getDeliveryInfo()

Calculate delivery date information Similar to Magento's getMenzzoIndexLimitShippingDay method

public getDeliveryInfo([string|null $dispo = null ][, string|null $customPhrase = null ][, bool $isInStock = false ][, SaleProduct|null $saleProduct = null ][, DateTime|null $referenceDate = null ]) : string
Parameters
$dispo : string|null = null

The availability date in Ymd format

$customPhrase : string|null = null

Custom phrase for formatting (e.g., "Livraison entre le %s et le %s")

$isInStock : bool = false

Whether the product is in stock

$saleProduct : SaleProduct|null = null

The sale product for additional context

$referenceDate : DateTime|null = null

Explicit reference date used when the product is already in stock

Return values
string

The formatted delivery information

getEntityManager()

Getter of the Entity Manager

public getEntityManager() : EntityManager
Return values
EntityManager

getOrderDeliveryInfo()

Get delivery information for a sale product Similar to Magento's getOrderDeliveryInfo method

public getOrderDeliveryInfo(SaleProduct $saleProduct) : string
Parameters
$saleProduct : SaleProduct
Return values
string

The delivery information message

getProductDispo()

Get the availability date (dispo) for a sale product

public getProductDispo(SaleProduct $saleProduct) : string|null

This method determines the "dispo" based on:

  1. If the sale product has a container assigned: use the container's arrival date
  2. Otherwise: use the sale product's own availability fields (dispoClientDate or available)
Parameters
$saleProduct : SaleProduct
Return values
string|null

The availability date in Ymd format, or null if not available

setEntityManager()

Setter of the Entity Manager

public setEntityManager(EntityManager $em) : mixed
Parameters
$em : EntityManager

the Entity Manager

setStoreToLocale()

Set the store to locale mapping

public setStoreToLocale(array<string|int, mixed> $storeToLocale) : mixed
Parameters
$storeToLocale : array<string|int, mixed>

setTranslator()

Set the translator

public setTranslator(TranslatorInterface $translator) : mixed
Parameters
$translator : TranslatorInterface

getLanguageCode()

Convert full locale to language code for translator Converts 'fr_FR' to 'fr', 'de_DE' to 'de', etc.

protected getLanguageCode(string $locale) : string
Parameters
$locale : string

Full locale (e.g., 'fr_FR', 'de_DE')

Return values
string

Language code (e.g., 'fr', 'de')

getLocaleForStore()

Get the locale for a given store ID

protected getLocaleForStore(int $storeId) : string
Parameters
$storeId : int
Return values
string

Locale code (e.g., 'fr_FR', 'de_DE')

getMonthName()

Get the translated month name

private getMonthName(DateTime $date[, string $langCode = 'fr' ]) : string
Parameters
$date : DateTime
$langCode : string = 'fr'

The language code to translate to (e.g., 'fr', 'de', 'es')

Return values
string

normalizeAvailabilityValue()

Normalize a raw availability value returned by SaleProduct.

private normalizeAvailabilityValue(mixed $availability) : string|null

Accepts numeric strings (dates in Ymd format) and non-empty textual statuses such as "Fin de produit". Returns null when the provided value cannot be interpreted as a meaningful availability indicator.

Parameters
$availability : mixed
Return values
string|null

        
On this page

Search results