ProductAutoEndListener
in package
Table of Contents
Properties
- $connection : mixed
- $container : mixed
- $logger : mixed
- $rabbitMqService : mixed
Methods
- __construct() : mixed
- getRealQty() : mixed
- Retrieves the real quantity from a consolidation value or directly returns the provided quantity.
- onProductAutoEnd() : mixed
- getProductCompositionRealQty() : int
- Calculates the real quantity of product composition based on the parent product quantity and composition quantity.
- isProductAutoEndToForce() : array<string|int, mixed>
- Determines if a product should be automatically marked as "end to force" based on its composition and database details.
- processComposedProducts() : array<string|int, mixed>|null
- Processes composed products based on their composition offer and determines product quantities and auto-end state.
Properties
$connection
private
mixed
$connection
$container
private
mixed
$container
$logger
private
mixed
$logger
$rabbitMqService
private
mixed
$rabbitMqService
Methods
__construct()
public
__construct(LoggerInterface $logger, RabbitMqService $rabbitMqService, ContainerInterface $container, Connection $connection) : mixed
Parameters
- $logger : LoggerInterface
- $rabbitMqService : RabbitMqService
- $container : ContainerInterface
- $connection : Connection
getRealQty()
Retrieves the real quantity from a consolidation value or directly returns the provided quantity.
public
getRealQty(mixed $consolidationQty, mixed $qty) : mixed
Parameters
- $consolidationQty : mixed
-
A possible JSON string containing quantity information.
- $qty : mixed
-
The default quantity to return if consolidationQty is not utilized.
Return values
mixed —The resolved quantity based on consolidation data or the provided quantity.
onProductAutoEnd()
public
onProductAutoEnd(ProductAutoEndEvent $event) : mixed
Parameters
- $event : ProductAutoEndEvent
getProductCompositionRealQty()
Calculates the real quantity of product composition based on the parent product quantity and composition quantity.
private
getProductCompositionRealQty(int $parentProductQty, int $compositionQty) : int
Parameters
- $parentProductQty : int
-
The quantity of the parent product.
- $compositionQty : int
-
The quantity required for one composition.
Return values
int —The calculated real quantity of product composition, or 0 if the parent product quantity is less than the composition quantity.
isProductAutoEndToForce()
Determines if a product should be automatically marked as "end to force" based on its composition and database details.
private
isProductAutoEndToForce(array<string|int, mixed> $productsComposition) : array<string|int, mixed>
Parameters
- $productsComposition : array<string|int, mixed>
-
An array of product SKUs representing the product composition.
Return values
array<string|int, mixed> —An associative array containing:
- 'isAutoEnd' (bool): Indicates whether the product is set to auto-end.
- 'qty' (int|null): The quantity of the product, or null if not applicable.
- 'consolidation_qty' (int|null): The consolidation quantity of the product, if available.
processComposedProducts()
Processes composed products based on their composition offer and determines product quantities and auto-end state.
private
processComposedProducts(string $productCompositionOffre) : array<string|int, mixed>|null
Parameters
- $productCompositionOffre : string
-
The string representation of product composition, where items are separated by semicolons.
Return values
array<string|int, mixed>|null —An array containing 'isAutoEnd' status and calculated 'realQty' if composition processing results in auto-end, or null otherwise.