/**
  * @api
  *
  * @param array $productIds
  * @param \Generated\Shared\Transfer\LocaleTransfer $locale
  *
  * @return \Orm\Zed\Product\Persistence\SpyProductQuery
  */
 public function queryExportableProductsByLocale(array $productIds, LocaleTransfer $locale)
 {
     $query = $this->getFactory()->createProductQuery();
     $query->filterByIdProduct($productIds, Criteria::IN)->useSpyProductLocalizedAttributesQuery()->filterByFkLocale($locale->getIdLocale())->endUse()->addSelectColumn(SpyProductTableMap::COL_SKU)->addSelectColumn(SpyProductLocalizedAttributesTableMap::COL_ATTRIBUTES)->addSelectColumn(SpyProductLocalizedAttributesTableMap::COL_NAME);
     $query->useSpyProductAbstractQuery()->useSpyProductAbstractLocalizedAttributesQuery()->filterByFkLocale($locale->getIdLocale())->endUse()->endUse()->addAsColumn('abstract_attributes', SpyProductAbstractLocalizedAttributesTableMap::COL_ATTRIBUTES);
     return $query;
 }
Exemplo n.º 2
0
 /**
  * @param \Generated\Shared\Transfer\LocaleTransfer $locale
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  *
  * @return array
  */
 public function exportStorageByLocale(LocaleTransfer $locale, OutputInterface $output)
 {
     $results = [];
     $types = array_keys($this->exporter->getCollectorPlugins());
     $availableTypes = $this->getAvailableCollectorTypes($types);
     $output->writeln('');
     $output->writeln(sprintf('<fg=yellow>Locale:</fg=yellow> <fg=white>%s</fg=white>', $locale->getLocaleName()));
     $output->writeln('<fg=yellow>-------------</fg=yellow>');
     foreach ($availableTypes as $type) {
         if (!in_array($type, $types)) {
             $output->write('<fg=yellow> * </fg=yellow><fg=green>' . $type . '</fg=green> ');
             $output->write('<fg=white>N/A</fg=white>');
             $output->writeln('');
             continue;
         }
         $result = $this->exporter->exportByType($type, $locale, $output);
         $this->handleResult($result);
         if ($result instanceof BatchResultInterface) {
             if ($this->nothingWasProcessed($result)) {
                 continue;
             }
             $results[$type] = $result;
         }
     }
     return $results;
 }
Exemplo n.º 3
0
 /**
  * @param array $translations
  *
  * @return array
  */
 protected function installKeysAndTranslations(array $translations)
 {
     Propel::getConnection()->beginTransaction();
     $results = [];
     foreach ($translations as $keyName => $data) {
         $results[$keyName]['created'] = false;
         if (!$this->keyManager->hasKey($keyName)) {
             $this->keyManager->createKey($keyName);
             $results[$keyName]['created'] = true;
         }
         foreach ($data['translations'] as $localeName => $text) {
             $locale = new LocaleTransfer();
             $locale->setLocaleName($localeName);
             $results[$keyName]['translation'][$localeName]['text'] = $text;
             $results[$keyName]['translation'][$localeName]['created'] = false;
             $results[$keyName]['translation'][$localeName]['updated'] = false;
             if (!$this->translationManager->hasTranslation($keyName, $locale)) {
                 $this->translationManager->createAndTouchTranslation($keyName, $locale, $text, true);
                 $results[$keyName]['translation'][$localeName]['created'] = true;
             } elseif ($this->translationManager->getTranslationByKeyName($keyName, $locale)->getValue() !== $text) {
                 $this->translationManager->updateAndTouchTranslation($keyName, $locale, $text, true);
                 $results[$keyName]['translation'][$localeName]['updated'] = true;
             }
         }
     }
     Propel::getConnection()->commit();
     return $results;
 }
 /**
  * @param string $localeName
  * @param array $localizedBlock
  *
  * @return \Generated\Shared\Transfer\LocaleTransfer
  */
 protected function createLocale($localeName, array $localizedBlock)
 {
     $locale = new LocaleTransfer();
     $locale->setLocaleName($localeName);
     $locale->setIdLocale((int) $localizedBlock[LocalizedBlockForm::FIELD_FK_LOCALE]);
     return $locale;
 }
 /**
  * @return \Generated\Shared\Transfer\LocaleTransfer
  */
 protected function createLocaleTransfer()
 {
     $locale = $this->getLocaleFacade()->getCurrentLocale();
     $localeTransfer = new LocaleTransfer();
     $localeTransfer->fromArray($locale->toArray());
     return $localeTransfer;
 }
Exemplo n.º 6
0
 /**
  * @param \Generated\Shared\Transfer\ProductConcreteTransfer $productConcreteTransfer
  *
  * @return bool
  */
 public function writeProduct(ProductConcreteTransfer $productConcreteTransfer)
 {
     $this->productStatement->execute([':sku' => $productConcreteTransfer->getSku(), ':isActive' => (int) $productConcreteTransfer->getIsActive(), ':attributes' => json_encode($productConcreteTransfer->getAttributes()), ':productAbstractSku' => $productConcreteTransfer->getProductAbstractSku()]);
     foreach ($productConcreteTransfer->getLocalizedAttributes() as $localizedAttributes) {
         $this->attributesStatement->execute([':productSku' => $productConcreteTransfer->getSku(), ':name' => $localizedAttributes->getName(), ':attributes' => json_encode($localizedAttributes->getAttributes()), ':fkLocale' => $this->localeTransfer->getIdLocale()]);
     }
     return true;
 }
Exemplo n.º 7
0
 /**
  * @param array $locales
  *
  * @return \Generated\Shared\Transfer\LocaleTransfer
  */
 private function buildLocaleTransferObject(array $locales)
 {
     $locale = new LocaleTransfer();
     $locale->setIdLocale($locales[0]);
     $locale->setLocaleName($this->locales[$locales[0]]);
     $locale->setIsActive(true);
     return $locale;
 }
 /**
  * @param \Orm\Zed\Category\Persistence\SpyCategoryNode $node
  *
  * @return string
  */
 protected function buildPath(SpyCategoryNode $node)
 {
     $pathTokens = $this->categoryQueryContainer->queryPath($node->getIdCategoryNode(), $this->locale->getIdLocale(), false, true)->find();
     $formattedPath = [];
     foreach ($pathTokens as $path) {
         $formattedPath[] = $path['name'];
     }
     return '/' . implode('/', $formattedPath);
 }
 /**
  * @param array $resultSet
  * @param array $processedResultSet
  * @param \Generated\Shared\Transfer\LocaleTransfer $locale
  *
  * @return array
  */
 public function processDataForExport(array &$resultSet, array $processedResultSet, LocaleTransfer $locale)
 {
     foreach ($resultSet as $index => $productRawData) {
         if (isset($processedResultSet[$index], $processedResultSet[$index]['product_concrete_collection'])) {
             $this->processVariants($processedResultSet[$index]['product_concrete_collection'], $locale->getIdLocale());
         }
     }
     return $processedResultSet;
 }
Exemplo n.º 10
0
 /**
  * @param string $url
  * @param \Generated\Shared\Transfer\LocaleTransfer $locale
  * @param string $resourceType
  * @param int $idResource
  *
  * @return \Orm\Zed\Url\Persistence\SpyUrl
  */
 public function createUrl($url, LocaleTransfer $locale, $resourceType, $idResource)
 {
     $this->checkUrlDoesNotExist($url);
     $fkLocale = $locale->getIdLocale();
     if ($fkLocale === null) {
         $fkLocale = $this->localeFacade->getLocale($locale->getLocaleName())->getIdLocale();
     }
     $urlEntity = new SpyUrl();
     $urlEntity->setUrl($url)->setFkLocale($fkLocale)->setResource($resourceType, $idResource)->save();
     return $urlEntity;
 }
Exemplo n.º 11
0
 /**
  * @param \Orm\Zed\Category\Persistence\SpyCategoryNode $node
  *
  * @return void
  */
 protected function renderChildren(SpyCategoryNode $node)
 {
     $children = $this->queryContainer->queryFirstLevelChildrenByIdLocale($node->getPrimaryKey(), $this->locale->getIdLocale())->find();
     $deleteLink = '/category-tree/index/delete-node?id=';
     $deleteString = '<br/>click to delete';
     $this->addClosureConnections($node);
     $this->graph->addNode($this->getNodeHash($node), ['URL' => $deleteLink . $node->getPrimaryKey(), 'label' => $this->getNodeName($node) . $deleteString, 'fontsize' => $this->fontSize]);
     foreach ($children as $child) {
         $this->graph->addNode($this->getNodeHash($child), ['URL' => $deleteLink . $child->getPrimaryKey(), 'label' => $this->getNodeName($child) . $deleteString, 'fontsize' => $this->fontSize]);
         $this->graph->addEdge($this->getNodeHash($node), $this->getNodeHash($child));
         /*
          * Recursive call
          */
         $this->renderChildren($child);
     }
 }
Exemplo n.º 12
0
 /**
  * @param array $collectedSet
  * @param \Generated\Shared\Transfer\LocaleTransfer $locale
  * @param \Spryker\Zed\Collector\Business\Exporter\Writer\Storage\TouchUpdaterSet $touchUpdaterSet
  *
  * @return array
  */
 protected function collectData(array $collectedSet, LocaleTransfer $locale, TouchUpdaterSet $touchUpdaterSet)
 {
     $setToExport = [];
     foreach ($collectedSet as $index => $collectedItemData) {
         $touchKey = $this->collectKey($collectedItemData[CollectorConfig::COLLECTOR_RESOURCE_ID], $locale->getLocaleName(), $collectedItemData);
         $setToExport[$touchKey] = $this->processCollectedItem($touchKey, $collectedItemData, $touchUpdaterSet);
     }
     return $setToExport;
 }
Exemplo n.º 13
0
 /**
  * @param \Generated\Shared\Transfer\CategoryTransfer $category
  * @param \Generated\Shared\Transfer\LocaleTransfer $locale
  * @param \Orm\Zed\Category\Persistence\SpyCategoryAttribute $categoryAttributeEntity
  *
  * @return void
  */
 protected function saveCategoryAttribute(CategoryTransfer $category, LocaleTransfer $locale, SpyCategoryAttribute $categoryAttributeEntity)
 {
     $categoryAttributeEntity->fromArray($category->toArray());
     $categoryAttributeEntity->setFkCategory($category->getIdCategory());
     $categoryAttributeEntity->setFkLocale($locale->getIdLocale());
     $categoryAttributeEntity->save();
 }
 /**
  * @param \Generated\Shared\Transfer\LocaleTransfer $localeTransfer
  *
  * @return \Propel\Runtime\ActiveQuery\Criteria
  */
 protected function getLocaleCriteria(LocaleTransfer $localeTransfer)
 {
     $localeCriteria = new Criteria();
     $localeCriteria->addAnd(PavCmsLocalizedBlockTableMap::COL_FK_LOCALE, $localeTransfer->getIdLocale(), Criteria::EQUAL);
     $localeCriteria->_or();
     $localeCriteria->addAnd(PavCmsLocalizedBlockTableMap::COL_ID_CMS_LOCALIZED_BLOCK, null, Criteria::ISNULL);
     return $localeCriteria;
 }
Exemplo n.º 15
0
 /**
  * Finds all glossary keys and creates missing translations as empty to be able to touch the page.
  *
  * @param int $idPage
  * @param \Generated\Shared\Transfer\LocaleTransfer $localeTransfer
  *
  * @return void
  */
 protected function createTranslationsForLocale($idPage, LocaleTransfer $localeTransfer)
 {
     $glossaryKeyCollection = $this->getQueryContainer()->queryGlossaryKeyMappingsByPageId($idPage)->innerJoinGlossaryKey()->withColumn(SpyGlossaryKeyTableMap::COL_KEY, 'glossaryKey')->find();
     foreach ($glossaryKeyCollection as $glossaryKeyEntity) {
         $key = $glossaryKeyEntity->getGlossaryKey()->getKey();
         $translation = $this->getQueryContainer()->queryKeyWithTranslationByKeyAndLocale($key, $localeTransfer->getIdLocale())->findOne();
         if ($translation !== null) {
             continue;
         }
         $this->getFactory()->getGlossaryFacade()->createAndTouchTranslation($key, $localeTransfer, '');
     }
 }
Exemplo n.º 16
0
 /**
  * @api
  *
  * @param int $idCategoryNode
  * @param \Generated\Shared\Transfer\LocaleTransfer $locale
  *
  * @return \Generated\Shared\Transfer\UrlTransfer|null
  */
 public function getResourceUrlByCategoryNodeIdAndLocale($idCategoryNode, LocaleTransfer $locale)
 {
     $urlManager = $this->getFactory()->createUrlManager();
     return $urlManager->getResourceUrlByCategoryNodeAndLocaleId($idCategoryNode, $locale->getIdLocale());
 }
Exemplo n.º 17
0
 /**
  * @param int $idProductConcrete
  * @param \Generated\Shared\Transfer\LocaleTransfer $locale
  *
  * @return bool
  */
 protected function hasProductConcreteAttributes($idProductConcrete, LocaleTransfer $locale)
 {
     $query = $this->productQueryContainer->queryProductConcreteAttributeCollection($idProductConcrete, $locale->getIdLocale());
     return $query->count() > 0;
 }
Exemplo n.º 18
0
 /**
  * @api
  *
  * @param \Propel\Runtime\ActiveQuery\ModelCriteria $expandableQuery
  * @param \Generated\Shared\Transfer\LocaleTransfer $locale
  *
  * @return $this
  */
 public function joinProductQueryWithLocalizedAttributes(ModelCriteria $expandableQuery, LocaleTransfer $locale)
 {
     $expandableQuery->addJoin(SpyProductAbstractTableMap::COL_ID_PRODUCT_ABSTRACT, SpyProductAbstractLocalizedAttributesTableMap::COL_FK_PRODUCT_ABSTRACT, Criteria::INNER_JOIN);
     $expandableQuery->addJoin(SpyProductAbstractLocalizedAttributesTableMap::COL_FK_LOCALE, SpyLocaleTableMap::COL_ID_LOCALE, Criteria::INNER_JOIN);
     $expandableQuery->addAnd(SpyLocaleTableMap::COL_ID_LOCALE, $locale->getIdLocale(), Criteria::EQUAL);
     $expandableQuery->addAnd(SpyLocaleTableMap::COL_IS_ACTIVE, true, Criteria::EQUAL);
     $expandableQuery->addJoinObject((new Join(SpyProductAbstractTableMap::COL_ID_PRODUCT_ABSTRACT, SpyUrlTableMap::COL_FK_RESOURCE_PRODUCT_ABSTRACT, Criteria::LEFT_JOIN))->setRightTableAlias('product_urls'), 'productUrlsJoin');
     $expandableQuery->addJoinCondition('productUrlsJoin', 'product_urls.fk_locale = ' . SpyLocaleTableMap::COL_ID_LOCALE);
     $expandableQuery->addJoinObject(new Join(SpyProductTableMap::COL_ID_PRODUCT, SpyProductLocalizedAttributesTableMap::COL_FK_PRODUCT, Criteria::INNER_JOIN), 'productAttributesJoin');
     $expandableQuery->addJoinCondition('productAttributesJoin', SpyProductLocalizedAttributesTableMap::COL_FK_LOCALE . ' = ' . SpyLocaleTableMap::COL_ID_LOCALE);
     $expandableQuery->withColumn(SpyProductAbstractTableMap::COL_ID_PRODUCT_ABSTRACT, 'id_product_abstract');
     $expandableQuery->withColumn(SpyProductAbstractTableMap::COL_ATTRIBUTES, 'abstract_attributes');
     $expandableQuery->withColumn(SpyProductAbstractLocalizedAttributesTableMap::COL_ATTRIBUTES, 'abstract_localized_attributes');
     $expandableQuery->withColumn("GROUP_CONCAT(spy_product.attributes SEPARATOR '\$%')", 'concrete_attributes');
     $expandableQuery->withColumn("GROUP_CONCAT(spy_product_localized_attributes.attributes SEPARATOR '\$%')", 'concrete_localized_attributes');
     $expandableQuery->withColumn('GROUP_CONCAT(product_urls.url)', 'product_urls');
     $expandableQuery->withColumn(SpyProductAbstractLocalizedAttributesTableMap::COL_NAME, 'abstract_name');
     $expandableQuery->withColumn('GROUP_CONCAT(spy_product_localized_attributes.name)', 'concrete_names');
     return $this;
 }
Exemplo n.º 19
0
 /**
  * @param int $idCategoryNode
  * @param \Generated\Shared\Transfer\LocaleTransfer $locale
  *
  * @return \Orm\Zed\Category\Persistence\SpyCategoryNode[]
  */
 protected function getCategoryChildren($idCategoryNode, LocaleTransfer $locale)
 {
     return $this->getFactory()->getCategoryQueryContainer()->queryChildren($idCategoryNode, $locale->getIdLocale(), false, false)->find();
 }
Exemplo n.º 20
0
 /**
  * @param int $idLocale
  *
  * @throws \Spryker\Zed\Cms\Business\Exception\LocaleNotFoundException
  *
  * @return \Generated\Shared\Transfer\LocaleTransfer
  */
 protected function getLocaleTransfer($idLocale)
 {
     $localEntity = $this->cmsQueryContainer->queryLocaleById($idLocale)->findOne();
     if ($localEntity === null) {
         throw new LocaleNotFoundException(sprintf('Locale with id %s not found', $idLocale));
     }
     $localTransfer = new LocaleTransfer();
     $localTransfer->fromArray($localEntity->toArray());
     return $localTransfer;
 }
 /**
  * @api
  *
  * @param string $term
  * @param \Generated\Shared\Transfer\LocaleTransfer $locale
  *
  * @return \Orm\Zed\Product\Persistence\SpyProductAbstractQuery
  */
 public function queryProductsAbstractBySearchTerm($term, LocaleTransfer $locale)
 {
     $query = $this->getFactory()->createProductAbstractQuery();
     $query->addJoin(SpyProductAbstractTableMap::COL_ID_PRODUCT_ABSTRACT, SpyProductAbstractLocalizedAttributesTableMap::COL_FK_PRODUCT_ABSTRACT, Criteria::INNER_JOIN)->addJoin(SpyProductAbstractLocalizedAttributesTableMap::COL_FK_LOCALE, SpyLocaleTableMap::COL_ID_LOCALE, Criteria::INNER_JOIN)->addAnd(SpyLocaleTableMap::COL_ID_LOCALE, $locale->getIdLocale(), Criteria::EQUAL)->addAnd(SpyLocaleTableMap::COL_IS_ACTIVE, true, Criteria::EQUAL)->withColumn(SpyProductAbstractLocalizedAttributesTableMap::COL_NAME, 'name')->withColumn(SpyProductAbstractTableMap::COL_ATTRIBUTES, 'abstract_attributes')->withColumn(SpyProductAbstractLocalizedAttributesTableMap::COL_ATTRIBUTES, 'abstract_localized_attributes');
     $query->groupByAttributes();
     $query->groupByIdProductAbstract();
     if (trim($term) !== '') {
         $term = '%' . mb_strtoupper($term) . '%';
         $query->where('UPPER(' . SpyProductAbstractTableMap::COL_SKU . ') LIKE ?', $term, \PDO::PARAM_STR)->_or()->where('UPPER(' . SpyProductAbstractLocalizedAttributesTableMap::COL_NAME . ') LIKE ?', $term, \PDO::PARAM_STR);
     }
     return $query;
 }
Exemplo n.º 22
0
 /**
  * @param string $categoryName
  * @param \Generated\Shared\Transfer\LocaleTransfer $locale
  *
  * @throws \Spryker\Zed\Category\Business\Exception\MissingCategoryException
  *
  * @return int
  */
 public function getCategoryIdentifier($categoryName, LocaleTransfer $locale)
 {
     $categoryQuery = $this->queryContainer->queryCategoryAttributesByName($categoryName, $locale->getIdLocale());
     $category = $categoryQuery->findOne();
     if (!$category) {
         throw new MissingCategoryException(sprintf('Tried to retrieve missing attributes of category %s, locale %s', $categoryName, $locale->getLocaleName()));
     }
     return $category->getFkCategory();
 }
Exemplo n.º 23
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')]);
 }
Exemplo n.º 24
0
 /**
  * @param int $idChild
  * @param \Generated\Shared\Transfer\LocaleTransfer $localeTransfer
  *
  * @return string
  */
 protected function generateChildUrl($idChild, LocaleTransfer $localeTransfer)
 {
     $parentList = $this->categoryTreeReader->getPathParents($idChild, $localeTransfer->getIdLocale());
     $pathTokens = [];
     foreach ($parentList as $parent) {
         /** @var \Orm\Zed\Category\Persistence\SpyCategoryClosureTable $parent */
         $pathTokens[] = $parent->toArray();
     }
     return $this->generateUrlFromPathTokens($pathTokens);
 }
Exemplo n.º 25
0
 /**
  * @param int $idCmsLocalizedBlock
  *
  * @throws \Pav\Zed\CmsBlock\Business\Exception\CmsBlockNotFoundException
  * @return \Generated\Shared\Transfer\BlockTransfer|null
  */
 public function getLocalizedById($idCmsLocalizedBlock)
 {
     $localizedBlockEntity = $this->queryContainer->queryLocalizedBlockById($idCmsLocalizedBlock)->findOne();
     if ($localizedBlockEntity === null) {
         return null;
     }
     $localizedBlockTransfer = new BlockLocalizedTransfer();
     $localizedBlockTransfer->fromArray($localizedBlockEntity->toArray(), true);
     $localeTransfer = new LocaleTransfer();
     $localeTransfer->setLocaleName($localizedBlockEntity->getSpyLocale()->getLocaleName());
     $localeTransfer->setIdLocale($localizedBlockEntity->getSpyLocale()->getIdLocale());
     $localizedBlockTransfer->setLocale($localeTransfer);
     $blockTransfer = $this->getById($localizedBlockEntity->getFkCmsBlock());
     $blockTransfer->addLocalizedBlocks($localizedBlockTransfer);
     return $blockTransfer;
 }
Exemplo n.º 26
0
 /**
  * @param array $item
  *
  * @return \Generated\Shared\Transfer\UrlTransfer
  */
 protected function getYvesProductUrl(array $item)
 {
     $yvesProductUrl = $this->urlFacade->getUrlByIdProductAbstractAndIdLocale($item[SpyProductAbstractTableMap::COL_ID_PRODUCT_ABSTRACT], $this->localeTransfer->getIdLocale());
     return $yvesProductUrl;
 }
Exemplo n.º 27
0
 /**
  * @param \Orm\Zed\Cms\Persistence\SpyCmsPage $cmsPageEntity
  *
  * @return \Generated\Shared\Transfer\LocaleTransfer
  */
 protected function getLocaleTransfer(SpyCmsPage $cmsPageEntity)
 {
     $localeTransfer = $this->getFactory()->getLocaleFacade()->getCurrentLocale();
     $url = $cmsPageEntity->getSpyUrls()->getFirst();
     if ($url) {
         $localeTransfer = new LocaleTransfer();
         $localeTransfer->fromArray($url->getSpyLocale()->toArray());
     }
     return $localeTransfer;
 }
Exemplo n.º 28
0
 /**
  * @param string $keyName
  * @param \Generated\Shared\Transfer\LocaleTransfer $locale
  *
  * @return \Generated\Shared\Transfer\TranslationTransfer
  */
 public function getTranslationByKeyName($keyName, LocaleTransfer $locale)
 {
     $translation = $this->getTranslationEntityByNames($keyName, $locale->getLocaleName());
     return $this->convertEntityToTranslationTransfer($translation);
 }