Search
 
SCRIPT & CODE EXAMPLE
 

PHP

magento2 get full details of order collection

<?php
ini_set('display_errors', 1);
ini_set('memory_limit', '160000M');
ini_set('max_execution_time', 0);

use MagentoFrameworkAppBootstrap;
require __DIR__ . '/app/bootstrap.php';

$params = $_SERVER;
$bootstrap = Bootstrap::create(BP, $params);
$obj = $bootstrap->getObjectManager();
$state = $obj->get('MagentoFrameworkAppState');
$state->setAreaCode('frontend');

$order_coll = $obj->get('MagentoSalesModelOrder')->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('MagentoFrameworkAppResourceConnection');
    $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;
}
?>
Comment

PREVIOUS NEXT
Code Example
Php :: magento2 get full details of order collection using root script 
Php :: job with queue name in laravel 
Php :: laravel intersect 
Php :: showing custom post type in wordpress website 
Php :: create a laravel project 
Php :: php define array first 10 number 
Php :: create model, controller and migration in single command laravel 
Php :: jquery greater than or equal to 
Php :: laravel validation string type 
Php :: enum in migration laravel 
Php :: connect rabbitMQ 
Php :: php http method 
Php :: wordpress create comment programmatically 
Php :: laravel localization 
Php :: fgets in php 
Php :: get admin url wordpress 
Php :: laravel post request page csrf disable 
Php :: googlee traduction 
Php :: popular cms 
Php :: php + set timezone berlin 
Php :: is null php 
Php :: json_encode() 
Php :: php string literal 
Php :: if is page woocommerce 
Php :: laravel Access to HMLHttpRequest from origin has been blocked by CORS policy: No Access-Control-Allow-Origin 
Php :: laravel pluck 
Php :: laravel restrict route 
Php :: laravel update multiple select query 
Php :: laravel file uploads 
Php :: how to check if file is empty in php 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =