Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento - get children of quote item

Tags:

magento

I am attempting to retrieve the quote items that have a particular parent_item_id

I actually have an instance of the parent quote item which I retrieved like so:

$parentQuoteItem = Mage::getModel("sales/quote_item")->load($quoteItemId);

How can I extract the children of this quote item?

I have tried calling the getChildren() method but unfortunately its giving an empty array:

$parentQuoteItem->getChildren()

Any help is greatly appreciated :)

---------------UPDATE-----------------------------

I kinda solved the issue with the following code:

$aChildQuoteItems = Mage::getModel("sales/quote_item")
                                ->getCollection()
                                ->setQuote($mQuote)
                                ->addFieldToFilter("parent_item_id", $quoteItemId);
like image 963
Gabriel Spiteri Avatar asked Jun 23 '11 14:06

Gabriel Spiteri


1 Answers

You probably need to load the quote first before calling getparent/child on the item...

$parent_quote = Mage::getModel("sales/quote")->load($quote_id);
$q_item = $quote->getItemById('q_item_id_looking_for')->getChildren();
// do something with them...
like image 54
Steve Ross Avatar answered Jan 03 '23 22:01

Steve Ross