public function items() { $catalogProductSet = new CCatalogProductSet(); $arSets = $catalogProductSet->getAllSetsByProduct($this->id(), CCatalogProductSet::TYPE_SET); /** @var Bundle $shop */ $shop = \TAO::bundle('Shop'); $items = array(); foreach ($arSets as $arSet) { $items[] = $shop->getProductById($arSet['ID']); } return $items; }
private function addProduct($data) { /** @var \TAO\Bundle\Shop\Bundle $shop */ $shop = \TAO::bundle('Shop'); foreach ($data as $productData) { $isProductSet = !empty($productData['items']); if ($isProductSet) { $items = array(); foreach ($productData['items'] as $itemData) { $items[] = $shop->getProduct($itemData['name'], $itemData['price'], isset($itemData['description']) ? $itemData['description'] : '', $itemData['parameters']); } $product = $shop->getProductSet($productData['name'], $productData['price'], isset($productData['description']) ? $productData['description'] : '', $items); } else { $product = $shop->getProduct($productData['name'], $productData['price'], isset($productData['description']) ? $productData['description'] : '', $productData['parameters']); } $shop->addProductToCart($product, $productData['quantity']); } }
/** * @return mixed */ public static function routeBundles() { global $DB; $uri = $_SERVER['REQUEST_URI']; $p = strpos($uri, '?'); if ($p > 0) { $uri = substr($uri, 0, $p); } foreach (\TAO::$routes as $re => $data) { $route = self::routeOne($uri, $re, $data); if (is_array($route)) { self::checkComposite($route); if (isset($route['element_of'])) { return self::dispatchElement($route); } if (isset($route['elements_of'])) { return self::dispatchElements($route); } if (isset($route['section_of'])) { return self::dispatchSection($route); } if (isset($route['sections_of'])) { return self::dispatchSections($route); } } } foreach (\TAO::$bundles as $name => $bundle) { $content = $bundle->routeStaticPage($uri); if (!empty($content)) { return $content; } $route = $bundle->route($uri); if (is_array($route)) { $rbundle = isset($route['bundle']) ? \TAO::bundle($route['bundle']) : $bundle; return $rbundle->dispatch($route); } } return self::routeElement($uri); }
/** * Navigation constructor. * @param bool|false $data */ public function __construct($data = false) { static $counter = 0; $counter++; if ($data === 'route') { $this->defaultTemplate = 'route'; $this->isRoute = true; return; } if (!$data) { $data = 'navigation'; } if (is_string($data)) { return $this->initRoot($data); } if (is_array($data)) { if (!isset($data['id'])) { $data['id'] = 'default' . $counter; } if (isset($data['url']) && isset($data['title'])) { $this->id = $data['id']; $this->url = $data['url']; $this->title = $data['title']; $this->parent = $data['parent']; $this->level = $this->parent->level + 1; if (isset($data['flag'])) { $this->flag = $data['flag']; unset($data['flag']); } if (isset($data['match'])) { $this->match = $data['match']; unset($data['match']); } if (isset($data['selected'])) { $this->selected = $data['selected']; unset($data['selected']); } unset($data['id']); unset($data['url']); unset($data['title']); unset($data['parent']); self::$byIds[$this->id] = $this; if (isset($data['sub'])) { $sub = $data['sub']; if (\TAO::isIterable($sub)) { $this->addArray($sub); } elseif (is_string($sub)) { if (preg_match('{^(infoblock|bundle|sections):(.+)$}', $sub, $m)) { $object = $m[1]; $code = trim($m[2]); $method = 'navigationTree'; if (preg_match('{^(.+):(.+)$}', $code, $m)) { $code = trim($m[1]); $method = trim($m[2]); } if ($object == 'sections') { $object = 'infoblock'; $method = 'navigationTreeSections'; } if ($object == 'infoblock') { $this->addArray(\TAO::infoblock($code)->{$method}($this, $data)); } elseif ($object == 'bundle') { $this->addArray(\TAO::bundle($code)->{$method}($this, $data)); } } } elseif (is_callable($sub)) { $this->addArray(call_user_func($sub, $this, $data)); } unset($data['sub']); } $this->data = $data; return; } } print 'Invalid navigation node<hr>'; var_dump($data); die; }
/** * @return bool|mixed */ public function bundle() { if (is_null($this->_bundle)) { $this->_bundle = false; $code = $this->getMnemocode(); $bundle = \TAO::getOption("infoblock.{$code}.bundle"); if ($bundle) { $this->_bundle = $bundle; } else { $class = get_class($this); if (preg_match('{^(TAO|App)\\\\Bundle\\\\([^\\\\]+)\\\\}', $class, $m)) { $name = $m[2]; $this->_bundle = \TAO::bundle($name); } } } return $this->_bundle; }