customer_2_addresses.php 803 B

12345678910111213141516171819202122232425
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. use Magento\Customer\Api\AddressRepositoryInterface;
  8. use Magento\Customer\Api\Data\AddressInterface;
  9. use Magento\TestFramework\Helper\Bootstrap;
  10. require __DIR__ . '/../../Customer/_files/customer.php';
  11. $objectManager = Bootstrap::getObjectManager();
  12. $addressData = include __DIR__ . '/address_data.php';
  13. /** @var AddressRepositoryInterface $repository */
  14. $repository = $objectManager->get(AddressRepositoryInterface::class);
  15. foreach ($addressData as $data) {
  16. /** @var AddressInterface $address */
  17. $address = $objectManager->create(AddressInterface::class, ['data' => $data]);
  18. $address->setCustomerId($customer->getId());
  19. $repository->save($address);
  20. }