/** * @return bool */ protected function loadBundleChildElements() { $bundleChildList = Provider::getSetItems($this); if (empty($bundleChildList)) { return null; } /** @var Basket $baseBasketCollection */ $baseBasketCollection = $this->getCollection(); /** @var Order $order */ $order = $baseBasketCollection->getOrder(); /** @var Basket $bundleCollection */ $bundleCollection = BasketBundleCollection::create($baseBasketCollection->getSiteId()); if ($order !== null) { $bundleCollection->setOrder($order); } foreach ($bundleChildList as $bundleBasketListDat) { foreach ($bundleBasketListDat["ITEMS"] as $bundleDat) { $bundleFields = static::clearBundleItemFields($bundleDat); $bundleFields['CURRENCY'] = $this->getCurrency(); if ($this->getId() > 0) { $bundleFields['SET_PARENT_ID'] = $this->getId(); } /** @var BasketItem $basketItem */ $bundleBasketItem = BasketItem::create($bundleCollection, $bundleFields['MODULE'], $bundleFields['PRODUCT_ID']); if (!empty($bundleDat["PROPS"]) && is_array($bundleDat["PROPS"])) { /** @var BasketPropertiesCollection $property */ $property = $bundleBasketItem->getPropertyCollection(); $property->setProperty($bundleDat["PROPS"]); } $bundleFields['QUANTITY'] = $bundleFields['QUANTITY'] * $this->getQuantity(); $bundleBasketItem->setFieldsNoDemand($bundleFields); $bundleBasketItem->parentBasketItem = $this; $bundleBasketItem->parentId = $this->getBasketCode(); $bundleCollection->addItem($bundleBasketItem); } } if ($productList = Provider::getProductData($bundleCollection, array('QUANTITY', 'PRICE'))) { foreach ($productList as $productBasketCode => $productDat) { if ($bundleBasketItem = $bundleCollection->getItemByBasketCode($productBasketCode)) { unset($productDat['DISCOUNT_LIST']); $bundleBasketItem->setFieldsNoDemand($productDat); } } } $this->bundleCollection = $bundleCollection; return $bundleCollection; }