Here’s another caution sign if you’re using the sales/quote
object’s deleteItem
or removeItem
method. If you look at the code that marks an item for deletion
$item->isDeleted(true);
if ($item->getHasChildren()) {
foreach ($item->getChildren() as $child) {
$child->isDeleted(true);
}
}
$parent = $item->getParentItem();
if ($parent) {
$parent->isDeleted(true);
}
In addition to removing the item you asked about, Magento will remove any child items (members of a bundled product) or any parent items (the bundled parent if you remove a specific child item of the bundled product). Likely the right behavior (although I could argue for an exception being thrown if you try to remove a child item), but one that leads to confusing results if you’re foreach
ing over a quotes items collection and removing items based on criteria.