Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SaveShipmentSource.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
11 
16 {
20  const SHIPMENT_ID = 'shipment_id';
21  const SOURCE_CODE = 'source_code';
22 
26  private $resourceConnection;
27 
31  public function __construct(
32  ResourceConnection $resourceConnection
33  ) {
34  $this->resourceConnection = $resourceConnection;
35  }
36 
42  public function execute(int $shipmentId, string $sourceCode)
43  {
44  $connection = $this->resourceConnection->getConnection();
45  $tableName = $this->resourceConnection->getTableName('inventory_shipment_source');
46 
47  $data = [
48  self::SHIPMENT_ID => $shipmentId,
49  self::SOURCE_CODE => $sourceCode
50  ];
51 
52  $connection->insertOnDuplicate($tableName, $data, [self::SOURCE_CODE]);
53  }
54 }
$tableName
Definition: trigger.php:13
$sourceCode
Definition: inventory.phtml:11
$connection
Definition: bulk.php:13