Ejemplo n.º 1
0
 /**
  * @param Category|Content|Article $entity
  * @param int|null                 $languageId
  *
  * @return Seo[]
  *
  * @throws \InvalidArgumentException
  */
 public function getEntitySeo($entity, $languageId = null)
 {
     if ($entity instanceof Category) {
         $type = 'oxcategory';
     } elseif ($entity instanceof Article) {
         $type = 'oxarticle';
     } elseif ($entity instanceof Content) {
         $type = 'oxcontent';
     } else {
         throw new \InvalidArgumentException();
     }
     $queryBuilder = $this->getEntityManager()->getRepository($this->getRepository())->createQueryBuilder('s');
     $queryBuilder->where('s.type = :type')->andWhere('s.objectId = :id')->andWhere('s.shopId = :shopId');
     $parameters = ['type' => $type, 'id' => $entity->getId(), 'shopId' => $this->getShopId()];
     if ($languageId !== null) {
         $queryBuilder->andWhere('s.lang = :lang');
         $parameters['lang'] = $languageId;
     }
     $query = $queryBuilder->getQuery()->setParameters($parameters);
     return $query->getResult();
 }
Ejemplo n.º 2
0
 /**
  * Transforms Category entity into ES document.
  *
  * @param Category         $category
  * @param CategoryDocument $document
  */
 public function transformCategoryToDocument(Category $category, CategoryDocument $document)
 {
     $document->setId($category->getId());
     $document->setActive($category->isActive());
     $document->setHidden($category->isHidden());
     $document->setLeft($category->getLeft());
     $document->setRight($category->getRight());
     $document->setRootId($category->getRoot()->getId());
     $document->setSort($category->getSort());
     $document->setTitle($category->getTitle());
     $document->setDescription($category->getDesc());
     $document->setLongDescription($category->getLongDesc());
     $document->setAttributes($this->attrToDocService->transform($category->getAttributes()));
     $this->extractUrls($category, $document);
     $parent = $category->getParent();
     $parentId = $parent ? $parent->getId() : null;
     if (empty($parentId) === false) {
         $document->setParentId($parentId);
     } else {
         $document->setParentId('oxrootid');
     }
 }