Beispiel #1
0
 /**
  * @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;
 }
Beispiel #2
0
 /**
  * @param BasketItemBase $basketItem
  * @return bool
  */
 public static function loadBundleChild(BasketItemBase $basketItem)
 {
     /** @var BasketBundleCollection $collection */
     $collection = new BasketBundleCollection();
     $collection->setParentBasketItem($basketItem);
     if ($basketItem->getId() > 0) {
         return $collection->loadFromDB(array("SET_PARENT_ID" => $basketItem->getId(), "TYPE" => false));
     }
     return $collection;
 }