How can I access the data from new column to existing table in Magento2 [closed]
-
10-12-2020 - |
Question
I have added a new column (PIN_ID) to the existing magento 2 table('sales_order') by 'Setup/UpgradeSchema', what's the best practice to access(get or retrieve) the data?
PS
Solution
Using ObjectManager you can access your custom field of table,
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->get('Magento\Sales\Model\Order');
$order_information = $order->loadByIncrementId($order_id);
$orderItems = $order_information->getAllItems();
foreach ($orderItems as $item) {
$itemSku = $item->getPinId();
}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange