How can I access the data from new column to existing table in Magento2 [closed]

magento.stackexchange https://magento.stackexchange.com/questions/99782

  •  10-12-2020
  •  | 
  •  

質問

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

役に立ちましたか?

解決

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();
            }
ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top