$product = Mage::getModel('catalog/product')->load(10); // Load product with ID 10 $productId = $product->getProductId(); // Get product ID echo $productId; // Output: 10
$order = Mage::getModel('sales/order')->load(100); // Load order with ID 100 $items = $order->getAllItems(); // Get all items in order foreach ($items as $item) { $productId = $item->getProductId(); // Get product ID of item echo $productId . 'In this example, we load an order with ID 100 and then use the getAllItems method to retrieve all the items in the order. Then we use a foreach loop to iterate over each item and use the getProductId method to retrieve the product ID of each item. Finally, we output the product ID of each item. Package library: Magento_Core.
'; // Output: Product ID of each item }