I have a Custom attribute name ( product string ) on Product in which i have save a string i want to get that custom attribute value for ordered product.
I have getting the ordered product by this code
 $orderId = 32;
 $order = $block->getOrderData($orderId);
 foreach ($order->getAllVisibleItems() as $_item) {
 echo $_item->getId();
 echo $_item->getSku();
 echo $_item->getName();
 echo $_item->getProductType();
 echo $_item->getQtyOrdered();
 echo "<pre>";print_r($_item->debug());
}
 1 Answer 1
You can get it with $item->getProduct()->getData('attribute_code_here')
But there is a problem.
Actually a few:
- Product may have been deleted
 - the attribute value has been changed after the order was placed.
 - the attribute may have been deleted
 
The best approach would be to save the value of the product attribute on the order item when the order is placed.
Here are some examples on how you can do that
- 
 Thanks for the response and help. Actually my requirement is different anyway thanks for the link. @MariusPrits– Prits2020年08月08日 06:58:24 +00:00Commented Aug 8, 2020 at 6:58
 
Explore related questions
See similar questions with these tags.