Magento 2 Select from Db in a template

<?php
...
$om = \Magento\Framework\App\ObjectManager::getInstance();
 
$connection = $om->create('\Magento\Framework\App\ResourceConnection')->getConnection(\Magento\Framework\App\ResourceConnection::DEFAULT_CONNECTION);
 
$tblSalesOrder = $connection->getTableName('pinamondo_seotext');
$results = $connection->fetchAll('SELECT name FROM `'.$tblSalesOrder.'`');
 
var_dump($results);
...

Leave a Reply