Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
source.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
11 use Magento\InventoryApi\Api\Data\SourceInterfaceFactory;
14 
16 $sourceFactory = Bootstrap::getObjectManager()->get(SourceInterfaceFactory::class);
18 $dataObjectHelper = Bootstrap::getObjectManager()->get(DataObjectHelper::class);
20 $sourceRepository = Bootstrap::getObjectManager()->get(SourceRepositoryInterface::class);
21 
23 $source = $sourceFactory->create();
24 $dataObjectHelper->populateWithArray(
25  $source,
26  [
27  SourceInterface::SOURCE_CODE => 'source-code-1',
28  SourceInterface::NAME => 'source-name-1',
29  SourceInterface::CONTACT_NAME => 'source-contact-name',
30  SourceInterface::EMAIL => 'source-email',
31  SourceInterface::ENABLED => true,
32  SourceInterface::DESCRIPTION => 'source-description',
33  SourceInterface::LATITUDE => 11.123456,
34  SourceInterface::LONGITUDE => 12.123456,
35  SourceInterface::COUNTRY_ID => 'US',
36  SourceInterface::REGION_ID => 10,
37  SourceInterface::CITY => 'source-city',
38  SourceInterface::STREET => 'source-street',
39  SourceInterface::POSTCODE => 'source-postcode',
40  SourceInterface::PHONE => 'source-phone',
41  SourceInterface::FAX => 'source-fax',
42  SourceInterface::USE_DEFAULT_CARRIER_CONFIG => 0,
43  SourceInterface::USE_DEFAULT_CARRIER_CONFIG => false,
44  SourceInterface::CARRIER_LINKS => [],
45  ],
46  SourceInterface::class
47 );
$source
Definition: source.php:23
$dataObjectHelper
Definition: source.php:18
$sourceRepository
Definition: source.php:20
$sourceFactory
Definition: source.php:16