/** * Retrieve config section * * @param string $scopeType * @param string|\Magento\Framework\Object|null $scopeCode * @return \Magento\Framework\App\Config\DataInterface */ public function getScope($scopeType, $scopeCode = null) { $scopeCode = $this->_getScopeCode($scopeType, $scopeCode); $code = $scopeType . '|' . $scopeCode; if (!isset($this->_scopes[$code])) { $cacheKey = $this->_cacheId . '|' . $code; $data = $this->_cache->load($cacheKey); if ($data) { $data = unserialize($data); } else { $reader = $this->_readerPool->getReader($scopeType); if ($scopeType === \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT) { $data = $reader->read(); } else { $data = $reader->read($scopeCode); } $this->_cache->save(serialize($data), $cacheKey, [self::CACHE_TAG]); } $this->_scopes[$code] = $this->_dataFactory->create(['data' => $data]); } return $this->_scopes[$code]; }
private static function LoadConfig() { chdir(dirname(realpath(__FILE__))); self::$config = parse_ini_file("/config.ini"); if (self::$config != null) { self::$host = self::$config["host"]; self::$port = self::$config["port"]; self::$user = self::$config["login"]; self::$pwd = self::$config["password"]; self::$db = self::$config["db"]; self::$type = self::$config["type"]; } chdir(str_replace("Data", "", dirname(realpath(__FILE__)))); }
/** * @param array $context * @return string The rendered template */ public function render(array $context = array()) : string { $data = $this->dataFactory->create($context); return $this->_render($data); }
public function init($filter, $sorter, $paging, $type) { $this->filter = $filter; $this->sorter = $sorter; $this->paging = $paging; $productDa = new ProductDa(); $productResults = $productDa->getProductsFilterSortPaging($this->filter, $this->sorter, $this->paging); if (isset($productResults)) { if (isset($productResults['paging'])) { $resultPaging = $productResults['paging']; $paging->calTotalPages($resultPaging->totalItems); } if (isset($productResults['products'])) { $products = $productResults['products']; if (count($products) > 0) { foreach ($products as $product) { $productItem = new ProductItemModel(); $productItem->init($product); array_push($this->products, $productItem); } } } } $filters = DataFactory::getFilters($type, $this->filter); if (isset($filters)) { //provider filter if (isset($filters['providers'])) { $providers = $filters['providers']; $this->filterModel->providers = array(); if (count($providers) > 0) { foreach ($providers as $provider) { $provider->isActive = $provider->Id == $this->filter->providerId; $provider->activeClass = $provider->isActive ? "active" : ""; array_push($this->filterModel->providers, $provider); } } } //price filter if (isset($filters['prices'])) { $prices = $filters['prices']; $this->filterModel->price = new PriceFilterModel($prices->minPrice, $prices->maxPrice); } $this->filterModel->attrs = array(); //attributes filter if (isset($filters['attributeValues'])) { $attributeValues = $filters['attributeValues']; if (count($attributeValues) > 0) { foreach ($attributeValues as $attr) { $title = ""; $code = ""; if (isset($attr) && count($attr) > 0) { $title = $attr[0]->AttributeName; $code = $attr[0]->AttributeCode; } $filterItem = new FilterItemModel(); $filterItem->title = $title; $filterItem->code = $code; $filterItem->items = array(); foreach ($attr as $value) { $item = new AttributeFilterModel($value->Id, $value->Value); $item->attrId = $value->AttributeId; $item->Cnt = $value->Cnt; $item->isActive = false; if (isset($this->filter) && isset($this->filter->attrValues)) { foreach ($this->filter->attrValues as $filterAttr) { if ($filterAttr->value == $value->Id) { $item->isActive = true; break; } } } array_push($filterItem->items, $item); } array_push($this->filterModel->attrs, $filterItem); } } } //attributes filter if (isset($filters['otherAttributeValues'])) { $attributeValues = $filters['otherAttributeValues']; if (count($attributeValues) > 0) { $attrs = array(); foreach ($attributeValues as $attr) { if (!array_key_exists($attr->AttributeId, $attrs)) { $attrs[$attr->AttributeId] = $attr; } } if (count($attrs) > 0) { foreach ($attrs as $key => $value) { $filterItem = new FilterItemModel(); $filterItem->title = $value->AttributeName; $filterItem->code = $value->AttributeCode; $filterItem->items = array(); foreach ($attributeValues as $attrValue) { if ($attrValue->AttributeId == $key) { $item = new AttributeFilterModel($attrValue->Id, $attrValue->Value); $item->attrId = $attrValue->AttributeId; $item->Cnt = $attrValue->Cnt; $item->isActive = false; if (isset($this->filter) && isset($this->filter->attrValues)) { foreach ($this->filter->attrValues as $filterAttr) { if ($filterAttr->value == $attrValue->Id) { $item->isActive = true; break; } } } array_push($filterItem->items, $item); } } if (count($filterItem->items) > 0) { array_push($this->filterModel->attrs, $filterItem); } } } } } } }