UpdateProductsAutoEndAndManageStockCommand
extends ContainerAwareCommand
in package
Table of Contents
Properties
- $connection : mixed
- $logger : mixed
- $rabbitMqService : mixed
Methods
- __construct() : mixed
- getRealQty() : mixed
- Retrieves the real quantity from a consolidation value or directly returns the provided quantity.
- configure() : mixed
- execute() : int
- Executes the process of fetching product data, preparing it, and publishing messages to a queue.
- getProductCompositionRealQty() : int
- Calculates the real quantity of product compositions that can be created based on the parent product's quantity and the composition quantity.
- getProductsDetails() : array<string|int, mixed>
- Retrieves detailed information for a list of products based on their IDs.
- isProductAutoEndToForce() : array<string|int, mixed>
- Determines whether a product's auto-end property should be enforced based on its composition.
Properties
$connection
private
mixed
$connection
$logger
private
mixed
$logger
$rabbitMqService
private
mixed
$rabbitMqService
Methods
__construct()
public
__construct(Connection $connection, RabbitMqService $rabbitMqService, LoggerInterface $logger) : mixed
Parameters
- $connection : Connection
- $rabbitMqService : RabbitMqService
- $logger : LoggerInterface
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.
configure()
protected
configure() : mixed
execute()
Executes the process of fetching product data, preparing it, and publishing messages to a queue.
protected
execute(InputInterface $input, OutputInterface $output) : int
The method retrieves product information in batches, processes each product's details, and sends them as messages to a RabbitMQ queue for further handling. It continues until all products are processed or an error occurs. Errors are logged, and appropriate messages are displayed to the output.
Parameters
- $input : InputInterface
-
The input arguments and options to control the execution.
- $output : OutputInterface
-
The interface to display messages during the execution process.
Return values
int —Returns 0 on success or 1 if an error occurs.
getProductCompositionRealQty()
Calculates the real quantity of product compositions that can be created based on the parent product's quantity and the composition quantity.
private
getProductCompositionRealQty(int $parentProductQty, int $compositionQty) : int
Parameters
- $parentProductQty : int
-
The quantity of the parent product available.
- $compositionQty : int
-
The quantity of the composition required to form one product.
Return values
int —The number of complete product compositions that can be created.
getProductsDetails()
Retrieves detailed information for a list of products based on their IDs.
private
getProductsDetails(array<string|int, mixed> $productIds) : array<string|int, mixed>
It processes each product to determine its attributes such as auto-end status and real quantity, while also handling product compositions if applicable.
Parameters
- $productIds : array<string|int, mixed>
-
The list of product IDs for which details need to be retrieved.
Return values
array<string|int, mixed> —An associative array where each key is a product ID and the value is an array containing the product details like 'isAutoEnd' and 'realQty'.
isProductAutoEndToForce()
Determines whether a product's auto-end property should be enforced based on its composition.
private
isProductAutoEndToForce(array<string|int, mixed> $productsComposition) : array<string|int, mixed>
Parameters
- $productsComposition : array<string|int, mixed>
-
An array of products' SKUs representing their composition.
Return values
array<string|int, mixed> —An associative array containing:
- 'isAutoEnd' (bool): Indicates if the product should 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, or null if not applicable.