protected function StockTransactionQueryTrait::getLastEntityTransaction in Commerce Stock 8
Return the last transaction for a entity.
Parameters
string $entity_id: The id of the entity to.
Return value
obj The transaction.
6 calls to StockTransactionQueryTrait::getLastEntityTransaction()
- StockLevelTest::testTransactionData in modules/
field/ tests/ src/ Kernel/ StockLevelTest.php - Whether all data are correctly saved with the transaction.
- StockLevelWidgetsTest::testAbsoluteStockLevelWidget in modules/
field/ tests/ src/ Functional/ StockLevelWidgetsTest.php - Testing the commerce_stock_level_absolute widget.
- StockLevelWidgetsTest::testAbsoluteTransactionStockLevelWidgetSingleVariationMode in modules/
field/ tests/ src/ Functional/ StockLevelWidgetsTest.php - Tests the absolute stock level widget in single variation mode.
- StockLevelWidgetsTest::testDeprecatedWidget in modules/
field/ tests/ src/ Functional/ StockLevelWidgetsTest.php - Test the deprecated simple widget.
- StockLevelWidgetsTest::testSimpleTransactionStockLevelWidget in modules/
field/ tests/ src/ Functional/ StockLevelWidgetsTest.php - Tests the default simple transaction widget.
File
- modules/
local_storage/ tests/ src/ Kernel/ StockTransactionQueryTrait.php, line 19
Class
- StockTransactionQueryTrait
- Provides methods to query the transaction database.
Namespace
Drupal\Tests\commerce_stock_local\KernelCode
protected function getLastEntityTransaction($entity_id) {
$connection = \Drupal::database();
$query = $connection
->select('commerce_stock_transaction', 'txn')
->fields('txn')
->condition('entity_id', $entity_id)
->orderBy('id', 'DESC')
->range(0, 1);
return $query
->execute()
->fetchObject();
}