init
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\LingxingErp\Plugin\InventoryAdminUi;
|
||||
|
||||
use Esun\LingxingErp\Model\Warehouse\WarehouseRepository;
|
||||
use Magento\InventoryAdminUi\Ui\DataProvider\SourceDataProvider;
|
||||
|
||||
class SourceDataProviderPlugin
|
||||
{
|
||||
public function __construct(private readonly WarehouseRepository $warehouseRepository)
|
||||
{
|
||||
}
|
||||
|
||||
/** @param array<string, mixed> $result */
|
||||
public function afterGetData(SourceDataProvider $subject, array $result): array
|
||||
{
|
||||
if ($subject->getName() !== SourceDataProvider::SOURCE_FORM_NAME) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
foreach ($result as $sourceCode => &$sourceData) {
|
||||
if ($sourceCode === '' || !is_array($sourceData)) {
|
||||
continue;
|
||||
}
|
||||
if (!isset($sourceData['general']) || !is_array($sourceData['general'])) {
|
||||
continue;
|
||||
}
|
||||
if (array_key_exists('lingxing_wid', $sourceData['general'])) {
|
||||
continue;
|
||||
}
|
||||
$wid = $this->warehouseRepository->getWidForSource((string)$sourceCode);
|
||||
$sourceData['general']['lingxing_wid'] = $wid === null ? '' : (string)$wid;
|
||||
}
|
||||
unset($sourceData);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user