コード例 #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();
 }
コード例 #2
0
 /**
  * Adds product variant to document.
  *
  * @param ProductDocument $document
  * @param Article         $variant
  */
 protected function modifyVariant($document, $variant)
 {
     $variantObject = new VariantObject();
     $variantObject->setId($variant->getId());
     $variantObject->setActive($variant->isActive());
     $variantObject->setSku($variant->getArtNum());
     $variantObject->setTitle($variant->getTitle());
     $variantObject->setDescription($variant->getShortDesc());
     $variantObject->setPrice($variant->getPrice());
     $variantObject->setOldPrice($variant->getTPrice());
     $variantObject->setStock($variant->getStock());
     $variantObject->setAttributes($this->attrToDocService->transform($variant->getAttributes()));
     $this->extractExtensionData($variant, $variantObject);
     $document->addVariant($variantObject);
 }
コード例 #3
0
 /**
  * Extract article seo urls.
  *
  * @param Article         $article
  * @param ProductDocument $document
  */
 private function extractUrls(Article $article, $document)
 {
     $urls = [];
     $seoUrls = $article->getSeoUrls();
     if (count($seoUrls) > 0) {
         foreach ($seoUrls as $seo) {
             if ($seo->getLang() === $this->languageId) {
                 /** @var Seo $seo */
                 $urlObject = new UrlNested();
                 $urlObject->setUrl($seo->getSeoUrl());
                 $urls[] = $urlObject;
             }
         }
     }
     $document->setUrls(new \ArrayIterator($urls));
     $document->setExpiredUrls([]);
 }