if (!$client) { $client = new \SoapClient( self::$base_url . $type . ".wsdl", [ 'trace' => true, 'exceptions' => true, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, 'login' => self::$username, 'password' => self::$password, 'soap_version' => SOAP_1_2 ] ); self::$clients[$type] = $client; } return $client; } private static function request($type, $method, $params) { $client = self::get_client($type);
[ 'trace' => true, 'exceptions' => true, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, 'login' => self::$username, 'password' => self::$password, 'soap_version' => SOAP_1_2 ] ); self::$clients[$type] = $client; } return $client; }
self::$clients[$type] = $client; } return $client; } private static function request($type, $method, $params) { $client = self::get_client($type); $request = new \StdClass(); foreach ($params as $key => $value) { $request->$key = $value; } try { $result = $client->$method($request);
} return $result; } public static function cache_dealers() { $dealers = self::request("article", "getTecDocDealer", [ ])->tecDocDealer ?? []; $results = []; foreach ($dealers as $dealer) { $db_record = TecdocDealer::findOne($dealer->id); if (!$db_record) { $db_record = new TecdocDealer(); $db_record->id = $dealer->id;
} public static function get_dealers() { $cache_time = TecdocCache::dealer_cache_time(); $now = time(); if ($now - TecdocCache::dealer_cached_at() > $cache_time) { return self::cache_dealers(); } return TecdocDealer::find()->all(); } public static function cache_articles($vehicle_id, $article_group_id) { $vehicle_id = intval($vehicle_id);
])->groupBy("tecdoc_article.id"); } private static function filter_search_query($q) { $q = strtolower(trim(preg_replace('/\s+/', ' ', $q))); // remove dealer names from search query $all_dealers = self::get_dealers(); $dealer_names = []; foreach ($all_dealers as $dealer) { $dealer_names[] = $dealer->name; } usort($dealer_names, function ($a, $b){ return strlen($b) - strlen($a);
$q = str_replace(strtolower($name), "", $q); } return trim($q); } public static function search_articles($q = "") { $q = self::filter_search_query($q); $article_ids = []; if (strlen($q) < 3) { return TecdocArticle::find()->where(['tecdoc_article.id' => -1 ]); // üres } if (TecdocArticle::findOne($q)) { $article_ids[] = intval($q);
} $order = Yii::$app->request->get("order", "price_asc"); if ($order !== "price_asc" && $order !== "price_desc" && $order !== "stock_asc" && $order !== "stock_desc") { $order = "price_asc"; } $query = TecdocController::search_articles($q); $dealers_query = clone $query; $query = self::filter_dealers($query); $count_query = clone $query; $price_update_query = clone $query; $relavant_dealers = $dealers_query->leftJoin("tecdoc_dealer", "tecdoc_dealer.id = tecdoc_article.dealer_id")->groupBy("tecdoc_dealer.id")->all(); self::update_prices($price_update_query);
$args = $this->controller->bindActionParams($this, $params); Yii::debug('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()', __METHOD__); if (Yii::$app->requestedParams === null) { Yii::$app->requestedParams = $args; } return call_user_func_array([$this->controller, $this->actionMethod], $args); } }
} $result = null; if ($runAction && $this->beforeAction($action)) { // run the action $result = $action->runWithParams($params); $result = $this->afterAction($action, $result); // call afterAction on modules foreach ($modules as $module) { /* @var $module Module */
$parts = $this->createController($route); if (is_array($parts)) { /* @var $controller Controller */ list($controller, $actionID) = $parts; $oldController = Yii::$app->controller; Yii::$app->controller = $controller; $result = $controller->runAction($actionID, $params); if ($oldController !== null) { Yii::$app->controller = $oldController; } return $result; }
$params = $this->catchAll; unset($params[0]); } try { Yii::debug("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } $response = $this->getResponse(); if ($result !== null) {
{ try { $this->state = self::STATE_BEFORE_REQUEST; $this->trigger(self::EVENT_BEFORE_REQUEST); $this->state = self::STATE_HANDLING_REQUEST; $response = $this->handleRequest($this->getRequest()); $this->state = self::STATE_AFTER_REQUEST; $this->trigger(self::EVENT_AFTER_REQUEST); $this->state = self::STATE_SENDING_RESPONSE; $response->send();
require(__DIR__ . '/vendor/autoload.php'); require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php'); $config = require(__DIR__ . '/config/web.php'); (new yii\web\Application($config))->run();
$_GET = [ 'category_slug' => 'szezonalis-termekek', 'category_id' => '2', ]; $_SESSION = [ '__flash' => [], ];