cancel
Showing results for 
Search instead for 
Did you mean: 

Success page with configurable get product ID and not their parents

Success page with configurable get product ID and not their parents

I have a problem with a script in success page. I need to get the real product IDs of the order, now when i put an order with configurable products i get the id of the configurable product and not for the child which is in order.

 

i try to get the ids with

 

public function getItems(): array
{
return $this->_order ? $this->_order->getAllVisibleItems() : [];
}

and

public function getProductId($order_item)
{
$variationUniqueId = $this->_helper->getVariationUniqueId();
$productId = $order_item->getProductId();
if (! $variationUniqueId && $order_item->getParentItem()) {
$productId = $order_item->getParentItem()->getProductId();
}
$product = $this->_product->load($productId);

return $product->getData($this->_helper->getUniqueId());
}
1 REPLY 1

Re: Success page with configurable get product ID and not their parents

@pantelisgr 

Use the below code 

$this->_order->getAllItems()

Instead of the below code:

$this->_order->getAllVisibleItems()
Problem solved? Click Kudos and "Accept as Solution".
200+ Magento 2 Extensions for Enhanced Shopping Experience.