0

I am using the VnEcoms Magento Marketplace Extension for my project

Now I want to get all the items in the cart (all vendors' items together)

I tried all the possible ways

$cart = Mage::getModel('checkout/cart')->getQuote()->getAllItems();

and

$cart = Mage::getModel('checkout/cart')->getQuote()->getItemsCollection();

and

$cart = Mage::getModel('checkout/cart')->getQuote()->getAllVisibleItems();

But when I put them in a foreach() and var_dump() the data, it says it's empty. The same code works for a fresh install of Magento. So my guess is the extension somehow changes the default magento quote.

So what is the best way to get all items in the cart, in my case?


EDIT

After doing some research I found out that the VnEcoms extension generates individual quotes for each vendor. We can get the combined list of items in the cart like this

public function getCartItems(){
    $quotes = Mage::getSingleton('vendorscheckout/session')->getQuotes();
    $allCartItems = array();
    foreach ($quotes as $quote) {
        $cartItems = $quote->getAllItems();
        array_push($allCartItems, $cartItems);
     }
     return $allCartItems;
}
0

Can you try this :

$quote = Mage::getSingleton('checkout/session')->getQuote();
$cartItems = $quote->getAllVisibleItems();
foreach ($cartItems as $item) {
    $productId = $item->getProductId();
    $product = Mage::getModel('catalog/product')->load($productId); 
} 
  • I tried it. The code is not going inside foreach, meaning the quote is empty – Jay Ghosh Nov 15 '16 at 10:04

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.