I am trying to print the name of an item inside an order in Magento 2.3.3. The item is a variation, and for some reason $item->getName() doesn't return the full name of the item. Instead it returns some kind of a general name, like the parent of the variation or something.

This is the data from mysql from this item. The correct name is #1, but the getName() returns #2.

enter image description here

This is the code:

$order = $this->_objectManager->get('Magento\Sales\Api\Data\OrderInterface')->loadByIncrementId($OrderNumber);
$items = $order->getAllItems();
foreach($items as $item){
    echo "item:".$item->getName()."\n";

I tried some other ways to get the correct name,such as getData('name'). Also $item->getProductOptions()['simple_name'] both return the wrong name. Another thing that I tried is getting the name of the parent of the item:

$product = $this->_objectManager->create('Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable')->getParentIdsByChild($productId);
    $product = $this->_objectManager->create('Magento\Catalog\Model\Product')->load($product[0]);
    $name = $product->getName();


The item is a variation item ('configuable'). The main item is ID:1557, SKU:1109 One of the variations is ID:197, SKU:11096

My issue that even when I get product id 197, I am still getting the name of the parent item. How can I get the name of the item itself?

enter image description here

$product_t = $this->_objectManager->create('Magento\Catalog\Model\Product')->load(197);
echo $product_t->getSku()."\n";   //===> 11096 (correct)
echo $product_t->getName()."\n";  //===> תיק רחצה נתלה (wrong, name of parent variation)


I have found a mysql query that returns the real name of the item:

select value from catalog_product_entity_varchar left join eav_attribute on
eav_attribute.attribute_id = catalog_product_entity_varchar.attribute_id
eav_attribute.attribute_code='name' and

result[0] is the name of the variation that I am looking for:

enter image description here

Anyone knows how to do the same in code?

  • I have no idea but you can look into store part too. Dec 23, 2020 at 12:04

3 Answers 3


Although using object manager is not a good practice but just to guide you I'm using it. Change it into dependency method if it works. Add below code :

  $order = $objectManager->create('\Magento\Sales\Model\OrderRepository')->get($orderId);
  $orderItems = $order->getAllItems();
foreach ($orderItems as $item) {



For details visit this link. hope it helps.

  • This is exactly what I am doing and the getName() returns the wrong name
    – justadev
    Dec 23, 2020 at 11:39
  • Did you try with \Magento\Sales\Model\OrderRepository? Dec 23, 2020 at 11:40
  • Yes, I tried it now. Same issue. This looks like an issue with the item data, not the order data.
    – justadev
    Dec 23, 2020 at 11:47
  • Though the above solution should work but if it's not then perhaps you can try getting productId from $item and then get corresponding name from product catalog? Dec 23, 2020 at 12:33
  • I updated the question with some additional info. Maybe it helps?
    – justadev
    Dec 23, 2020 at 15:34

I think problem is your store view level data. Here is an example of getting product:

$order = $objectManager->get('\Magento\Sales\Model\OrderRepository')->get($orderId);
$productObj = $objectManager->get('Magento\Catalog\Model\ProductRepository');
$product = $productObj->getById($productId, false, $order->getStoreId());

Not tested code but you can modify it in your way.

  • Unfortunately no, I tried it right now, and it is still returning the wrong title.
    – justadev
    Dec 23, 2020 at 14:59
  • I updated the question with some additional info. Maybe it helps?
    – justadev
    Dec 23, 2020 at 15:34

This code worked:

foreach($items as $item){
    $product_obj = $item->getProduct();
    $productId = $item->getProductId();
    $name = $product_obj->getResource()->getAttributeRawValue($productId,'name',0);
    echo "name:$name\n";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.