I try to get qty for a single product which came from o grouped product after a finish my order
In my observer i can take the product name, id,price, attribute id and so on but i can't take the qty
I have the fallowing code in my observer:
public function execute(\Magento\Framework\Event\Observer $observer)
{
$order = $observer->getEvent()->getOrder();
$order_id = $order->getIncrementId();
foreach($order->getAllItems() as $item){
$ProdustIds = $item->getProductId();
// product name
$proName[] = $item->getName();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customProduct = $objectManager->get('Magento\Catalog\Model\Product')->load($ProdustIds);
$productAttributeId = $customProduct->getData('attribute_set_id');
//get attribute set name for each product
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$attributeSet = $objectManager->create('Magento\Eav\Api\AttributeSetRepositoryInterface');
$attributeSetRepository = $attributeSet->get($productAttributeId);
$attribute_set_name = $attributeSetRepository->getAttributeSetName();
$attribute_name = strtolower($attribute_set_name);
//get prodcut price
$productAttributePrice = $customProduct->getData('price');
//product qty
$productAttributeQty = $customProduct->getData('qty');
$proQty[] = $item->getQty();
I already tried with $productAttributeQty = $customProduct->getData('qty')
; and
$proQty[] = $item->getQty()
But is not working.
Does anyone know where is the problem?