0

Hi need toget the product id of in a quote item.i have the qoute id with me and tried the below code but product id does not seem to display from the quote.

$quoteId=784;
$quote = Mage::getModel('sales/quote')->getCollection()
->addFieldToFilter('entity_id', $quoteId)
->getFirstItem();
echo $pid = $quote[product_id] ;

Please help to get product id from quote id .

Thanks.

1

Use below code

$quoteId=784;
$quote = Mage::getModel('sales/quote')->load($quoteId);
$cartItems = $quote->getAllVisibleItems();
foreach ($cartItems as $item) {
    $productId = $item->getProductId();
}

EDIT: Use below code for quote id arrays

$quoteIds = array(1,2,3,4);
$productId = array();

foreach($quoteIds as $quoteId){
    $quote = Mage::getModel('sales/quote')->load($quoteId);
    $cartItems = $quote->getAllVisibleItems();
    foreach ($cartItems as $item) {
        $productId[] = $item->getProductId();
    }
}
echo "<pre>";
print_r($productId);
  • Hi can you help me to get product ids from array of quote ids – Melvin Feb 17 '17 at 10:31
  • updated answer please check it – Prashant Valanda Feb 17 '17 at 10:52
0

Use the below code to get product id in Magento 1.9

<?php 
    $items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
        foreach($items as $item)
        { 
            echo $item->getProductId();
        }
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.