35 lines
1.2 KiB
PHP
35 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace KupShop\WarehouseBundle\Util;
|
|
|
|
use Query\Operator;
|
|
|
|
class WorkerUtil extends \KupShop\CheckAppBundle\Util\WorkerUtil
|
|
{
|
|
public function getProductAdditionalData($id_product, $id_variation)
|
|
{
|
|
$data = parent::getProductAdditionalData($id_product, $id_variation);
|
|
|
|
if (findModule(\Modules::PRODUCTS_BATCHES)) {
|
|
$batchesSQL = sqlQueryBuilder()->select('p.batch_number_require, pb.id, pb.code, pb.date_expiry')
|
|
->fromProducts()
|
|
->joinVariationsOnProducts()
|
|
->leftJoin('p', 'products_batches', 'pb', 'p.id = pb.id_product AND pv.id <=> pb.id_variation')
|
|
->where(Operator::equalsNullable([
|
|
'p.id' => $id_product,
|
|
'pv.id' => $id_variation,
|
|
]))->execute()->fetchAllAssociative();
|
|
|
|
$data['batch_number_require'] = $batchesSQL[0]['batch_number_require'] ?? null;
|
|
|
|
$data['batches_numbers'] = array_filter(array_map(function ($batch) {
|
|
unset($batch['batch_number_require']);
|
|
|
|
return ($batch['id']) ? $batch : null;
|
|
}, $batchesSQL));
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
}
|