magento2 Dapatkan detail lengkap koleksi pesanan menggunakan skrip root
<?php
ini_set('display_errors', 1);
ini_set('memory_limit', '160000M');
ini_set('max_execution_time', 0);
use Magento\Framework\App\Bootstrap;
require __DIR__ . '/app/bootstrap.php';
$params = $_SERVER;
$bootstrap = Bootstrap::create(BP, $params);
$obj = $bootstrap->getObjectManager();
$state = $obj->get('Magento\Framework\App\State');
$state->setAreaCode('frontend');
$order_coll = $obj->get('Magento\Sales\Model\Order')->getCollection();
$order_coll->getSelect()
->join(array('order_item' => 'sales_order_item'),
'order_item.order_id = main_table.entity_id',getColumns('sales_order_item', 'soi_'));
$order_coll->getSelect()
->join(array('sales_grid'=>'sales_order_grid'),
'sales_grid.entity_id=main_table.entity_id',getColumns('sales_order_grid','sog_'));
foreach ($order_coll as $entity) {
echo "<pre>";
print_r($entity->getData());
echo "</pre>";
}
function getColumns($table,$prefix)
{
$resource = $GLOBALS['obj']->get('Magento\Framework\App\ResourceConnection');
$connection = $resource->getConnection();
$sql = "SHOW COLUMNS FROM `$table`;";
$result = $connection->fetchAll($sql);
$columns = array();
for ($i = 0; $i < count($result); $i++) {
array_push($columns,$result[$i]['Field']." as ".$prefix.$result[$i]['Field']);
}
return $columns;
}
?>
Dharmesh Tukadiya