简体   繁体   中英

can't work $itemObject->getProduct()->getName() in magento

I m trying to get product information through item object using getProduct() method of Mage_Sales_Quote_Item class without a for loop. Below is my nonworking code. How do I get data of product using the getProduct() method?

 $quoteId = 5;
    $quoteItemObject = Mage::getModel('sales/quote')->load($quoteId)->getAllItems();
    echo $quoteItemObject->getProduct()->getName();

$quoteItemObject returns an array of all items in the quote but not a separate item. You need to "foreach" it and get information for each item separately. Try something like this:

foreach ($quoteItemObject as $item) {
    echo $item->getProduct()->getName();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM