get(StockInterfaceFactory::class); /** @var DataObjectHelper $dataObjectHelper */ $dataObjectHelper = Bootstrap::getObjectManager()->get(DataObjectHelper::class); /** @var StockRepositoryInterface $stockRepository */ $stockRepository = Bootstrap::getObjectManager()->get(StockRepositoryInterface::class); $stocksData = [ [ // define only required and needed for tests fields StockInterface::STOCK_ID => 10, StockInterface::NAME => 'EU-stock', ], [ StockInterface::STOCK_ID => 20, StockInterface::NAME => 'US-stock', ], [ StockInterface::STOCK_ID => 30, StockInterface::NAME => 'Global-stock', ], ]; foreach ($stocksData as $stockData) { /** @var StockInterface $stock */ $stock = $stockFactory->create(); $dataObjectHelper->populateWithArray($stock, $stockData, StockInterface::class); $stockRepository->save($stock); }