Skip to content

Commit

Permalink
Fix indexing of assets
Browse files Browse the repository at this point in the history
  • Loading branch information
danrot committed Mar 30, 2023
1 parent 3c29ce2 commit 969c670
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/DocumentType/AbstractDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Valantic\ElasticaBridgeBundle\DocumentType;

use Elastica\Document as ElasticaDocument;
use Pimcore\Model\Asset;
use Pimcore\Model\DataObject\Concrete;
use Pimcore\Model\Document as PimcoreDocument;
use Pimcore\Model\Document\Listing as DocumentListing;
Expand Down Expand Up @@ -46,6 +47,10 @@ final public function getElasticsearchId(AbstractElement $element): string
return $element->getType() . $element->getId();
}

if ($element instanceof Asset) {
return DocumentInterface::TYPE_ASSET . $element->getId();
}

if ($element instanceof PimcoreDocument) {
return DocumentInterface::TYPE_DOCUMENT . $element->getId();
}
Expand All @@ -68,6 +73,10 @@ public function getListingClass(): string
return $this->getSubType() . '\Listing';
}

if (in_array($this->getType(), [DocumentInterface::TYPE_ASSET], true)) {
return $this->getSubType() . '\Listing';
}

if ($this->getType() === DocumentInterface::TYPE_DOCUMENT) {
// TODO: this listing doesn't seem to have an option to e.g. only list Hardlinks
return DocumentListing::class;
Expand Down

0 comments on commit 969c670

Please sign in to comment.