예제 #1
0
 /**
  * @param string $locale
  *
  * @return array
  */
 public function getCategories($locale)
 {
     $urlKey = $this->urlBuilder->generateKey([], $locale);
     $categories = $this->keyValueReader->get($urlKey);
     if ($categories) {
         return $categories;
     }
     return [];
 }
 /**
  * @param array $blockIds
  * @param string $locale
  *
  * @return array
  */
 public function fetchBlocksByIds(array $blockIds, $locale)
 {
     $blockKeys = [];
     foreach ($blockIds as $blockId) {
         $blockKeys[] = $this->keyBuilder->generateKey($blockId, $locale);
     }
     $blocks = $this->storageReader->getMulti($blockKeys);
     $decodedBlocks = [];
     foreach ($blocks as $key => $block) {
         $decodedBlocks[$key] = $this->decodeBlock($block);
     }
     return $decodedBlocks;
 }
예제 #3
0
 /**
  * @param string $url
  * @param string $localeName
  *
  * @return array|bool
  */
 public function matchUrl($url, $localeName)
 {
     $url = rawurldecode($url);
     $urlKey = $this->urlKeyBuilder->generateKey($url, $localeName);
     $urlDetails = $this->keyValueReader->get($urlKey);
     if ($urlDetails) {
         $data = $this->keyValueReader->get($urlDetails['reference_key']);
         if ($data) {
             return ['type' => $urlDetails['type'], 'data' => $data];
         }
     }
     return false;
 }
예제 #4
0
파일: Catalog.php 프로젝트: spryker/Catalog
 /**
  * @param array $ids
  * @param string|null $indexByKey
  *
  * @return array
  */
 public function getProductDataByIds(array $ids, $indexByKey = null)
 {
     $idKeys = [];
     foreach ($ids as $id) {
         $idKeys[] = $this->productKeyBuilder->generateKey($id, $this->locale);
     }
     $productsFromStorage = $this->storageReader->getMulti($idKeys);
     if ($productsFromStorage === null) {
         return [];
     }
     foreach ($productsFromStorage as $key => $product) {
         $productsFromStorage[$key] = $this->mergeAttributes(json_decode($product, true));
     }
     if ($indexByKey) {
         return $this->mapKeysToValue($indexByKey, $productsFromStorage);
     }
     return $productsFromStorage;
 }
 /**
  * @param array $categoryNode
  * @param string $locale
  *
  * @return array
  */
 public function createTreeFromCategoryNode(array $categoryNode, $locale)
 {
     $parents = array_slice(array_reverse($categoryNode[CategoryNodeKeyInterface::PARENTS]), 0, self::SUBTREE_DEPTH);
     $subtree = [];
     foreach ($parents as $parent) {
         $storageKey = $this->keyBuilder->generateKey($parent[CategoryNodeKeyInterface::NODE_ID], $locale);
         $parentCategory = $this->kvReader->get($storageKey);
         if (empty($subtree)) {
             $subtree = $parentCategory;
         }
         if ($parentCategory) {
             $parentCategory = $this->addCurrentSubtree($parentCategory, $subtree);
             $subtree = $parentCategory;
         }
     }
     if (empty($categoryNode[CategoryNodeKeyInterface::PARENTS]) || empty($subtree)) {
         $subtree = $categoryNode;
     }
     $subtree[self::SUBTREE_DEPTH_KEY] = self::SUBTREE_DEPTH;
     return $subtree;
 }
예제 #6
0
 /**
  * @param string $keyName
  *
  * @return void
  */
 protected function loadTranslation($keyName)
 {
     $key = $this->keyBuilder->generateKey($keyName, $this->localeName);
     $this->addTranslation($keyName, $this->storage->get($key));
 }
예제 #7
0
 /**
  * @param string $exportType
  * @param \Generated\Shared\Transfer\LocaleTransfer $locale
  * @param \DateTime $timestamp
  *
  * @return void
  */
 public function setLastExportMarkByTypeAndLocale($exportType, LocaleTransfer $locale, \DateTime $timestamp)
 {
     $timestampKey = $this->keyBuilder->generateKey($exportType, $locale->getLocaleName());
     $this->writer->write([$timestampKey => $timestamp->format('Y-m-d H:i:s')]);
 }
예제 #8
0
 /**
  * @param int $idProductAbstract
  *
  * @return mixed
  */
 public function getProductAbstractFromStorageById($idProductAbstract)
 {
     $key = $this->keyBuilder->generateKey($idProductAbstract, $this->locale);
     $product = $this->storage->get($key);
     return $product;
 }