21 $bundleItemList = array();
22 if (isset($fields[
'ITEMS']))
24 $bundleItemList = $fields[
'ITEMS'];
25 unset($fields[
'ITEMS']);
31 if (isset($fields[
'QUANTITY']))
34 $fields[
'QUANTITY'] += max($delta, 0);
37 $result = parent::applyRefreshResult($item, $fields);
38 if ($result->isSuccess())
42 $r = $this->applyBundleRefreshResult($item, $bundleItemList);
45 $result->addErrors($r->getErrors());
59 protected function applyBundleRefreshResult(
BasketItemBase $item, $bundleItemList)
66 $basketItemClassName = $registry->getBasketItemClassName();
69 $bundleCollection = $item->getBundleCollection();
70 $bundleIndexList = array();
72 foreach ($bundleCollection as $bundleItem)
74 $bundleIndexList[$bundleItem->getBasketCode()] = $bundleItem;
78 foreach ($bundleItemList as $bundleBasketItemData)
80 if (empty($bundleBasketItemData[
'MODULE']) || empty($bundleBasketItemData[
'PRODUCT_ID']))
84 if (!empty($bundleBasketItemData[
'PROPS']) && is_array($bundleBasketItemData[
'PROPS']))
86 $props = $bundleBasketItemData[
'PROPS'];
90 $bundleItem = $bundleCollection->getExistsItem($bundleBasketItemData[
'MODULE'], $bundleBasketItemData[
'PRODUCT_ID'], $props);
93 $bundleItem = $basketItemClassName::create($bundleCollection, $bundleBasketItemData[
'MODULE'], $bundleBasketItemData[
'PRODUCT_ID']);
96 $fields = array_intersect_key($bundleBasketItemData, $basketItemClassName::getSettableFieldsMap());
100 $result->addErrors($r->getErrors());
103 unset($bundleIndexList[$bundleItem->getBasketCode()]);
106 if ($bundleIndexList)
109 foreach ($bundleIndexList as $bundleItem)
111 $bundleItem->delete();