/** * Traces the search result into the s_statistic_search * * @param Criteria $criteria * @param ProductNumberSearchResult $result * @param Shop $shop */ public function logResult(Criteria $criteria, ProductNumberSearchResult $result, Shop $shop) { if (!$criteria->hasCondition('search')) { return; } /* @var $condition SearchTermCondition */ $condition = $criteria->getCondition('search'); $now = new \DateTime(); $this->connection->insert('s_statistics_search', ['datum' => $now->format('Y-m-d H:i:s'), 'searchterm' => $condition->getTerm(), 'results' => $result->getTotalCount(), 'shop_id' => $shop->getId()]); }
/** * {@inheritdoc} */ public function get(Shop $shop, $groupIds) { $context = $this->contextService->createShopContext($shop->getId(), ContextService::FALLBACK_CUSTOMER_GROUP); $result = []; $query = $this->getQuery($context); foreach ($groupIds as $groupId) { $query->setParameter(':id', $groupId); $data = $query->execute()->fetchAll(\PDO::FETCH_ASSOC); $result[$groupId] = $this->hydrateGroup($data); } return $result; }
/** * @param Shop $shop * @param ListProduct[] $products * @param $priceRules * @return array */ private function getCalculatedPrices($shop, $products, $priceRules) { $currencies = $this->identifierSelector->getShopCurrencyIds($shop->getId()); if (!$shop->isMain()) { $currencies = $this->identifierSelector->getShopCurrencyIds($shop->getParentId()); } $customerGroups = $this->identifierSelector->getCustomerGroupKeys(); $contexts = $this->getContexts($shop->getId(), $customerGroups, $currencies); $prices = []; foreach ($products as $product) { $number = $product->getNumber(); if (!isset($priceRules[$number])) { continue; } $rules = $priceRules[$number]; /**@var $context ProductContextInterface*/ foreach ($contexts as $context) { $customerGroup = $context->getCurrentCustomerGroup()->getKey(); $key = $customerGroup . '_' . $context->getCurrency()->getId(); $product->setCheapestPriceRule($rules[$customerGroup]); $this->priceCalculationService->calculateProduct($product, $context); if ($product->getCheapestPrice()) { $prices[$number][$key] = $product->getCheapestPrice(); } } } return $prices; }
/** * @param Shop $shop * @return array */ private function getCalculatedPricesMapping(Shop $shop) { $prices = []; $customerGroups = $this->identifierSelector->getCustomerGroupKeys(); $currencies = $this->identifierSelector->getShopCurrencyIds($shop->getId()); foreach ($currencies as $currency) { foreach ($customerGroups as $customerGroup) { $key = $customerGroup . '_' . $currency; $prices[$key] = $this->getPriceMapping(); } } return ['properties' => $prices]; }
/** * @param Shop $shop * @return string */ private function getIndexName(Shop $shop) { return $this->getPrefix() . $shop->getId(); }