- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2022
09:12 AM
02-10-2022
09:12 AM
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()); }
Labels:
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2022
01:21 AM
02-11-2022
01:21 AM
Re: Success page with configurable get product ID and not their parents
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.
200+ Magento 2 Extensions for Enhanced Shopping Experience.