Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields
GetSourceCodeByShipmentId Class Reference

Public Member Functions

 __construct (ResourceConnection $resourceConnection)
 
 execute (int $shipmentId)
 

Data Fields

const SHIPMENT_ID = 'shipment_id'
 
const SOURCE_CODE = 'source_code'
 

Detailed Description

Get source code by shipment Id

Definition at line 15 of file GetSourceCodeByShipmentId.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( ResourceConnection  $resourceConnection)
Parameters
ResourceConnection$resourceConnection

Definition at line 31 of file GetSourceCodeByShipmentId.php.

32  {
33  $this->resourceConnection = $resourceConnection;
34  }

Member Function Documentation

◆ execute()

execute ( int  $shipmentId)

Get the source code by shipment Id

Parameters
int$shipmentId
Returns
string|null

Definition at line 42 of file GetSourceCodeByShipmentId.php.

43  {
44  $connection = $this->resourceConnection->getConnection();
45  $tableName = $this->resourceConnection
46  ->getTableName('inventory_shipment_source');
47 
48  $select = $connection->select()
49  ->from($tableName, [
50  self::SOURCE_CODE => self::SOURCE_CODE
51  ])
52  ->where(self::SHIPMENT_ID . ' = ?', $shipmentId)
53  ->limit(1);
54 
55  $sourceCode = $connection->fetchOne($select);
56 
57  return $sourceCode ?: null;
58  }
$tableName
Definition: trigger.php:13
$sourceCode
Definition: inventory.phtml:11
$connection
Definition: bulk.php:13

Field Documentation

◆ SHIPMENT_ID

const SHIPMENT_ID = 'shipment_id'

Constant for fields in data array

Definition at line 20 of file GetSourceCodeByShipmentId.php.

◆ SOURCE_CODE

const SOURCE_CODE = 'source_code'

Definition at line 21 of file GetSourceCodeByShipmentId.php.


The documentation for this class was generated from the following file: