This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
@@ -0,0 +1,62 @@
<?php
declare(strict_types=1);
namespace Esun\LingxingErp\Setup\Patch\Data;
use Esun\LingxingErp\Model\Product\Attribute\Backend\WebsiteUnique;
use Magento\Catalog\Model\Product;
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class AddErpSkuProductAttribute implements DataPatchInterface
{
public function __construct(
private readonly ModuleDataSetupInterface $moduleDataSetup,
private readonly EavSetupFactory $eavSetupFactory
) {
}
public function apply(): self
{
$this->moduleDataSetup->getConnection()->startSetup();
$eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
$eavSetup->addAttribute(Product::ENTITY, 'erp_sku', [
'type' => 'varchar',
'label' => 'Lingxing ERP SKU',
'input' => 'text',
'backend' => WebsiteUnique::class,
'required' => false,
'user_defined' => true,
'global' => ScopedAttributeInterface::SCOPE_WEBSITE,
// One Lingxing ERP SKU may be paired with multiple Magento SKUs in the same Website.
'unique' => false,
'visible' => true,
'searchable' => false,
'filterable' => false,
'filterable_in_search' => false,
'visible_in_advanced_search' => false,
'visible_on_front' => false,
'used_for_sort_by' => false,
'used_in_product_listing' => true,
'is_used_in_grid' => true,
'is_visible_in_grid' => true,
'is_filterable_in_grid' => true,
'group' => 'General',
'sort_order' => 95,
]);
$this->moduleDataSetup->getConnection()->endSetup();
return $this;
}
public static function getDependencies(): array
{
return [];
}
public function getAliases(): array
{
return [];
}
}
@@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
namespace Esun\LingxingErp\Setup\Patch\Data;
use Esun\LingxingErp\Model\Api\Endpoint;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class BackfillLogApiPath implements DataPatchInterface
{
public function __construct(private readonly ModuleDataSetupInterface $moduleDataSetup)
{
}
public function apply(): self
{
$connection = $this->moduleDataSetup->getConnection();
$table = $this->moduleDataSetup->getTable('esun_lingxing_sync_log');
$connection->startSetup();
foreach ([
'store_sync' => Endpoint::STORE_LIST,
'order_create' => Endpoint::ORDER_CREATE,
'sku_pair_lookup' => Endpoint::PAIR_LIST,
'shipment_pull' => Endpoint::WMS_ORDER_LIST,
] as $operation => $apiPath) {
$connection->update(
$table,
['api_path' => $apiPath],
['operation = ?' => $operation, 'api_path IS NULL']
);
}
$connection->endSetup();
return $this;
}
public static function getDependencies(): array
{
return [];
}
public function getAliases(): array
{
return [];
}
}