/** * 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; }
/** * @see https://www.elastic.co/guide/en/elasticsearch/guide/current/analysis-intro.html * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-lang-analyzer.html * * @param Shop $shop * @return string[] */ public function get(Shop $shop) { $mapping = ['aa_DJ' => 'afar', 'aa_ER' => 'afar', 'aa_ET' => 'afar', 'af_NA' => 'afrikaans', 'af_ZA' => 'afrikaans', 'ak_GH' => 'akan', 'am_ET' => 'amharic', 'ar_AE' => 'arabic', 'ar_BH' => 'arabic', 'ar_DZ' => 'arabic', 'ar_EG' => 'arabic', 'ar_IQ' => 'arabic', 'ar_JO' => 'arabic', 'ar_KW' => 'arabic', 'ar_LB' => 'arabic', 'ar_LY' => 'arabic', 'ar_MA' => 'arabic', 'ar_OM' => 'arabic', 'ar_QA' => 'arabic', 'ar_SA' => 'arabic', 'ar_SD' => 'arabic', 'ar_SY' => 'arabic', 'ar_TN' => 'arabic', 'ar_YE' => 'arabic', 'as_IN' => 'assamese', 'az_AZ' => 'azerbaijani', 'be_BY' => 'belarusian', 'bg_BG' => 'bulgarian', 'bn_BD' => 'bengali', 'bn_IN' => 'bengali', 'bo_CN' => 'tibetan', 'bo_IN' => 'tibetan', 'bs_BA' => 'bosnian', 'byn_ER' => 'blin', 'ca_ES' => 'catalan', 'cch_NG' => 'atsam', 'cs_CZ' => 'czech', 'cy_GB' => 'welsh', 'da_DK' => 'danish', 'de_AT' => 'german', 'de_BE' => 'german', 'de_CH' => 'german', 'de_DE' => 'german', 'de_LI' => 'german', 'de_LU' => 'german', 'dv_MV' => 'divehi', 'dz_BT' => 'dzongkha', 'ee_GH' => 'ewe', 'ee_TG' => 'ewe', 'el_CY' => 'greek', 'el_GR' => 'greek', 'en_AS' => 'english', 'en_AU' => 'english', 'en_BE' => 'english', 'en_BW' => 'english', 'en_BZ' => 'english', 'en_CA' => 'english', 'en_GB' => 'english', 'en_GU' => 'english', 'en_HK' => 'english', 'en_IE' => 'english', 'en_IN' => 'english', 'en_JM' => 'english', 'en_MH' => 'english', 'en_MP' => 'english', 'en_MT' => 'english', 'en_NA' => 'english', 'en_NZ' => 'english', 'en_PH' => 'english', 'en_PK' => 'english', 'en_SG' => 'english', 'en_TT' => 'english', 'en_UM' => 'english', 'en_US' => 'english', 'en_VI' => 'english', 'en_ZA' => 'english', 'en_ZW' => 'english', 'es_AR' => 'spanish', 'es_BO' => 'spanish', 'es_CL' => 'spanish', 'es_CO' => 'spanish', 'es_CR' => 'spanish', 'es_DO' => 'spanish', 'es_EC' => 'spanish', 'es_ES' => 'spanish', 'es_GT' => 'spanish', 'es_HN' => 'spanish', 'es_MX' => 'spanish', 'es_NI' => 'spanish', 'es_PA' => 'spanish', 'es_PE' => 'spanish', 'es_PR' => 'spanish', 'es_PY' => 'spanish', 'es_SV' => 'spanish', 'es_US' => 'spanish', 'es_UY' => 'spanish', 'es_VE' => 'spanish', 'et_EE' => 'estonian', 'eu_ES' => 'basque', 'fa_AF' => 'persian', 'fa_IR' => 'persian', 'fi_FI' => 'finnish', 'fil_PH' => 'filipino', 'fo_FO' => 'faroese', 'fr_BE' => 'french', 'fr_CA' => 'french', 'fr_CH' => 'french', 'fr_FR' => 'french', 'fr_LU' => 'french', 'fr_MC' => 'french', 'fr_SN' => 'french', 'fur_IT' => 'friulian', 'ga_IE' => 'irish', 'gaa_GH' => 'ga', 'gez_ER' => 'geez', 'gez_ET' => 'geez', 'gl_ES' => 'galician', 'gsw_CH' => 'swiss german', 'gu_IN' => 'gujarati', 'gv_GB' => 'manx', 'ha_GH' => 'hausa', 'ha_NE' => 'hausa', 'ha_NG' => 'hausa', 'ha_SD' => 'hausa', 'haw_US' => 'hawaiian', 'he_IL' => 'hebrew', 'hi_IN' => 'hindi', 'hr_HR' => 'croatian', 'hu_HU' => 'hungarian', 'hy_AM' => 'armenian', 'id_ID' => 'indonesian', 'ig_NG' => 'igbo', 'ii_CN' => 'sichuan yi', 'is_IS' => 'icelandic', 'it_CH' => 'italian', 'it_IT' => 'italian', 'ja_JP' => 'japanese', 'ka_GE' => 'georgian', 'kaj_NG' => 'jju', 'kam_KE' => 'kamba', 'kcg_NG' => 'tyap', 'kfo_CI' => 'koro', 'kk_KZ' => 'kazakh', 'kl_GL' => 'kalaallisut', 'km_KH' => 'khmer', 'kn_IN' => 'kannada', 'ko_KR' => 'korean', 'kok_IN' => 'konkani', 'kpe_GN' => 'kpelle', 'kpe_LR' => 'kpelle', 'ku_IQ' => 'kurdish', 'ku_IR' => 'kurdish', 'ku_SY' => 'kurdish', 'ku_TR' => 'kurdish', 'kw_GB' => 'cornish', 'ky_KG' => 'kirghiz', 'ln_CD' => 'lingala', 'ln_CG' => 'lingala', 'lo_LA' => 'lao', 'lt_LT' => 'lithuanian', 'lv_LV' => 'latvian', 'mk_MK' => 'macedonian', 'ml_IN' => 'malayalam', 'mn_CN' => 'mongolian', 'mn_MN' => 'mongolian', 'mr_IN' => 'marathi', 'ms_BN' => 'malay', 'ms_MY' => 'malay', 'mt_MT' => 'maltese', 'my_MM' => 'burmese', 'nb_NO' => 'norwegian bokmål', 'nds_DE' => 'low german', 'ne_IN' => 'nepali', 'ne_NP' => 'nepali', 'nl_BE' => 'dutch', 'nl_NL' => 'dutch', 'nn_NO' => 'norwegian nynorsk', 'nr_ZA' => 'south ndebele', 'nso_ZA' => 'northern sotho', 'ny_MW' => 'nyanja', 'oc_FR' => 'occitan', 'om_ET' => 'oromo', 'om_KE' => 'oromo', 'or_IN' => 'oriya', 'pa_IN' => 'punjabi', 'pa_PK' => 'punjabi', 'pl_PL' => 'polish', 'ps_AF' => 'pashto', 'pt_BR' => 'portuguese', 'pt_PT' => 'portuguese', 'ro_MD' => 'romanian', 'ro_RO' => 'romanian', 'ru_RU' => 'russian', 'ru_UA' => 'russian', 'rw_RW' => 'kinyarwanda', 'sa_IN' => 'sanskrit', 'se_FI' => 'northern sami', 'se_NO' => 'northern sami', 'sh_BA' => 'serbo-croatian', 'sh_CS' => 'serbo-croatian', 'sh_YU' => 'serbo-croatian', 'si_LK' => 'sinhala', 'sid_ET' => 'sidamo', 'sk_SK' => 'slovak', 'sl_SI' => 'slovenian', 'so_DJ' => 'somali', 'so_ET' => 'somali', 'so_KE' => 'somali', 'so_SO' => 'somali', 'sq_AL' => 'albanian', 'sr_BA' => 'serbian', 'sr_CS' => 'serbian', 'sr_ME' => 'serbian', 'sr_RS' => 'serbian', 'sr_YU' => 'serbian', 'ss_SZ' => 'swati', 'ss_ZA' => 'swati', 'st_LS' => 'southern sotho', 'st_ZA' => 'southern sotho', 'sv_FI' => 'swedish', 'sv_SE' => 'swedish', 'sw_KE' => 'swahili', 'sw_TZ' => 'swahili', 'syr_SY' => 'syriac', 'ta_IN' => 'tamil', 'te_IN' => 'telugu', 'tg_TJ' => 'tajik', 'th_TH' => 'thai', 'ti_ER' => 'tigrinya', 'ti_ET' => 'tigrinya', 'tig_ER' => 'tigre', 'tn_ZA' => 'tswana', 'to_TO' => 'tonga', 'tr_TR' => 'turkish', 'ts_ZA' => 'tsonga', 'tt_RU' => 'tatar', 'ug_CN' => 'uighur', 'uk_UA' => 'ukrainian', 'ur_IN' => 'urdu', 'ur_PK' => 'urdu', 'uz_AF' => 'uzbek', 'uz_UZ' => 'uzbek', 've_ZA' => 'venda', 'vi_VN' => 'vietnamese', 'wal_ET' => 'walamo', 'wo_SN' => 'wolof', 'xh_ZA' => 'xhosa', 'yo_NG' => 'yoruba', 'zh_CN' => 'chinese', 'zh_HK' => 'chinese', 'zh_MO' => 'chinese', 'zh_SG' => 'chinese', 'zh_TW' => 'chinese', 'zu_ZA' => 'zulu']; $supported = ['arabic', 'armenian', 'basque', 'brazilian', 'bulgarian', 'catalan', 'chinese', 'cjk', 'czech', 'danish', 'dutch', 'english', 'finnish', 'french', 'galician', 'german', 'greek', 'hindi', 'hungarian', 'indonesian', 'irish', 'italian', 'latvian', 'norwegian', 'persian', 'portuguese', 'romanian', 'russian', 'sorani', 'spanish', 'swedish', 'turkish', 'thai']; $language = $shop->getLocale()->getLocale(); if (!isset($mapping[$language])) { return ['standard']; } $language = $mapping[$language]; $language = strtolower($language); if (!in_array($language, $supported)) { return ['standard']; } return [$language]; }
/** * Converts a shop doctrine model to a shop struct * @param \Shopware\Models\Shop\Shop $shop * @return Struct\Shop */ public function convertShop(Models\Shop\Shop $shop) { $struct = new Struct\Shop(); $struct->setId($shop->getId()); $struct->setName($shop->getName()); $struct->setHost($shop->getHost()); $struct->setPath($shop->getBasePath()); $struct->setUrl($shop->getBaseUrl()); $struct->setSecure($shop->getSecure()); $struct->setSecureHost($shop->getSecureHost()); $struct->setSecurePath($struct->getSecurePath()); if ($shop->getCategory()) { $struct->setCategory($this->convertCategory($shop->getCategory())); } return $struct; }
/** * @param Shop $shop * @param Product $product * @return bool */ private function isValid(Shop $shop, $product) { $valid = in_array($shop->getCategory()->getId(), $product->getCategoryIds()); if (!$valid) { return false; } return true; }
/** * Validates if the product is available in the current shop * @param int $productId * @param Shop $shop */ private function isProductAvailableInShop($productId, $shop) { $query = $this->connection->createQueryBuilder(); $query->select('categories.categoryID')->from('s_articles_categories_ro', 'categories')->where('categories.articleID = :productId')->andWhere('categories.categoryID = :categoryId')->setParameter(':productId', $productId)->setParameter(':categoryId', $shop->getCategory()->getId())->setMaxResults(1); return $query->execute()->fetch(\PDO::FETCH_COLUMN); }
/** * @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]; }
private function filterShopBlog(Shop $shop, $ids) { $query = $this->connection->createQueryBuilder(); $query->select('blog.id')->from('s_blog', 'blog')->innerJoin('blog', 's_categories', 'category', 'category.id = blog.category_id AND category.path LIKE :path')->andWhere('blog.id IN (:ids)')->setParameter(':path', '%|' . (int) $shop->getCategory()->getId() . '|%')->setParameter(':ids', $ids, Connection::PARAM_INT_ARRAY); return $query->execute()->fetchAll(\PDO::FETCH_COLUMN); }
/** * @param array $data * @return Shop */ public function hydrate($data) { $shop = new Shop(); $shop->setId((int) $data['__shop_id']); $shop->setIsDefault((bool) $data['__shop_default']); $shop->setName($data['__shop_name']); $shop->setTitle($data['__shop_title']); $shop->setFallbackId((int) $data['__shop_fallback_id']); $shop->setCurrency($this->currencyHydrator->hydrate($data)); $shop->setCustomerGroup($this->customerGroupHydrator->hydrate($data)); $shop->setCategory($this->categoryHydrator->hydrate($data)); $shop->setLocale($this->localeHydrator->hydrate($data)); $parent = $data; if ($data['parent']) { $parent = $data['parent']; } $shop->setTemplate($this->templateHydrator->hydrate($parent)); $shop->setParentId((int) $parent['__shop_id']); $shop->setHost($parent['__shop_host']); $shop->setPath($parent['__shop_base_path']); $shop->setUrl($data['__shop_base_url'] ?: $parent['__shop_base_url']); $shop->setSecure((bool) $parent['__shop_secure']); $shop->setSecureHost($parent['__shop_secure_host']); $shop->setSecurePath($parent['__shop_secure_base_path']); $hosts = []; if ($parent['__shop_hosts']) { $hosts = explode('\\n', $parent['__shop_hosts']); $hosts = array_unique(array_values(array_filter($hosts))); } $shop->setHosts($hosts); return $shop; }
/** * @param Shop $shop * @return string */ private function getIndexName(Shop $shop) { return $this->getPrefix() . $shop->getId(); }
private function getBlogIds(Shop $shop) { $query = $this->connection->createQueryBuilder(); $query->select('blog.id')->from('s_blog', 'blog')->innerJoin('blog', 's_categories', 'category', 'category.id = blog.category_id AND category.path LIKE :path')->setParameter(':path', '%|' . (int) $shop->getCategory()->getId() . '|%'); return $query->execute()->fetchAll(\PDO::FETCH_COLUMN); }