Пример #1
0
 /**
  * @param \Generated\Shared\Transfer\CmsBlockTransfer $cmsBlockTransfer
  *
  * @return array
  */
 public function getBlockByName(CmsBlockTransfer $cmsBlockTransfer)
 {
     $blockName = $cmsBlockTransfer->getName() . '-' . $cmsBlockTransfer->getType() . '-' . $cmsBlockTransfer->getValue();
     $key = $this->keyBuilder->generateKey($blockName, $cmsBlockTransfer->getLocale()->getLocaleName());
     $block = $this->storage->get($key);
     return $block;
 }
Пример #2
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 [];
 }
Пример #3
0
 /**
  * @param int $id
  *
  * @throws \Spryker\Client\Catalog\Model\Exception\ProductNotFoundException
  *
  * @return array
  */
 public function getProductDataById($id)
 {
     $productKey = $this->productKeyBuilder->generateKey($id, $this->locale);
     $productFromStorage = $this->storageReader->get($productKey);
     if (empty($productFromStorage)) {
         throw new ProductNotFoundException($id);
     }
     return $productFromStorage;
 }
Пример #4
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;
 }
 /**
  * @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 int $idProductAbstract
  *
  * @return mixed
  */
 public function getProductAbstractFromStorageById($idProductAbstract)
 {
     $key = $this->keyBuilder->generateKey($idProductAbstract, $this->locale);
     $product = $this->storage->get($key);
     return $product;
 }