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