在commerceservices 扩展中有Service -->Abstract 类AbstractDataImportService。
该类再次由 SampleDataImportService 和 CoreDataImportService 服务扩展。
SampleDataImportService 负责根据 localextension.xml 执行所选商店扩展(如电子、电动工具)的样本数据。
并在这个类中维护了执行层次结构。
代码 sn-p 如下。
@Override
protected void importProductCatalog(final String extensionName, final String productCatalogName)
{
// Load Units
getSetupImpexService().importImpexFile(
String.format("/%s/import/sampledata/productCatalogs/%sProductCatalog/classifications-units.impex", extensionName,
productCatalogName), false);
// Load Categories
getSetupImpexService().importImpexFile(
String.format("/%s/import/sampledata/productCatalogs/%sProductCatalog/categories.impex", extensionName,
productCatalogName), false);
getSetupImpexService().importImpexFile(
String.format("/%s/import/sampledata/productCatalogs/%sProductCatalog/categories-classifications.impex",
extensionName, productCatalogName), false);
// Load Suppliers
getSetupImpexService().importImpexFile(
String.format("/%s/import/sampledata/productCatalogs/%sProductCatalog/suppliers.impex", extensionName,
productCatalogName), false);
getSetupImpexService().importImpexFile(
String.format("/%s/import/sampledata/productCatalogs/%sProductCatalog/suppliers-media.impex", extensionName,
productCatalogName), false);
// Load medias for Categories as Suppliers loads some new Categories
getSetupImpexService().importImpexFile(
String.format("/%s/import/sampledata/productCatalogs/%sProductCatalog/categories-media.impex", extensionName,
productCatalogName), false);
// Load Products
getSetupImpexService().importImpexFile(
String.format("/%s/import/sampledata/productCatalogs/%sProductCatalog/products.impex", extensionName,
productCatalogName), false);
getSetupImpexService().importImpexFile(
String.format("/%s/import/sampledata/productCatalogs/%sProductCatalog/products-media.impex", extensionName,
productCatalogName), false);
getSetupImpexService().importImpexFile(
String.format("/%s/import/sampledata/productCatalogs/%sProductCatalog/products-classifications.impex", extensionName,
productCatalogName), false);
// Load Products Relations
getSetupImpexService().importImpexFile(
String.format("/%s/import/sampledata/productCatalogs/%sProductCatalog/products-relations.impex", extensionName,
productCatalogName), false);
// Load Products Fixes
getSetupImpexService().importImpexFile(
String.format("/%s/import/sampledata/productCatalogs/%sProductCatalog/products-fixup.impex", extensionName,
productCatalogName), false);
// Load Prices
getSetupImpexService().importImpexFile(
String.format("/%s/import/sampledata/productCatalogs/%sProductCatalog/products-prices.impex", extensionName,
productCatalogName), false);
// Load Stock Levels
getSetupImpexService().importImpexFile(
String.format("/%s/import/sampledata/productCatalogs/%sProductCatalog/products-stocklevels.impex", extensionName,
productCatalogName), false);
getSetupImpexService().importImpexFile(
String.format("/%s/import/sampledata/productCatalogs/%sProductCatalog/products-pos-stocklevels.impex", extensionName,
productCatalogName), false);
// Load Taxes
getSetupImpexService().importImpexFile(
String.format("/%s/import/sampledata/productCatalogs/%sProductCatalog/products-tax.impex", extensionName,
productCatalogName), false);
// Load Multi-Dimensial Products
importMultiDProductCatalog(extensionName, productCatalogName);
}