I hope it would be helpful for you. In below code I have used orderCollectionFactory to retrieve custom attribute value:
namespace Vendor\ModuleName\Model; use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollection; use Magento\Sales\Model\ResourceModel\Order\CollectionFactory; class YOURClass { /** * @var orderCollection */ private $orderCollection; /** * @var ProductCollection */ private $productCollection; /** * @var logger */ private $logger; public function __construct( Context $context, CollectionFactory $orderCollection, ProductCollection $productCollection, \Psr\Log\LoggerInterface $logger ) { parent::__construct($context); $this->orderCollection = $orderCollection; $this->productCollection = $productCollection; $this->logger = $logger; } public function execute() { $collection = $this->orderCollection->create() ->addAttributeToSelect('*') ->addFieldToFilter('increment_id', '000000003'); foreach ($collection->getItems() as $order) { foreach($order->getAllItems() as $item) { $this->_logger>logger->log('600', print_r($item->getProduct()->getData('custom_field'), true)); } } } }