DivanteLtd / coreshop-vsbridge

CoreShop Vue Storefront integration - first Progressive Web App (PWA) framework for Pimcore
https://vuestorefront.io
MIT License
74 stars 25 forks source link

Custom transformer support #42

Closed dkarlovi closed 4 years ago

dkarlovi commented 4 years ago

(note: this includes #41 since it's not merged yet, but required for this to work)

This PR allows to add custom mappings to the ingested Elasticsearch documents, for example adding category images (which Coreshop supports, but VSF does not, AFAIK).

It works like this:

  1. developer decorates the document mapper in their Pimcore services:
    AppBundle\VueStorefront\DocumentMapper\CategoryDocumentMapper:
        decorates: CoreShop2VueStorefrontBundle\Bridge\DocumentMapper\DocumentCategoryMapper
  2. add AppBundle to ingested bundles for ES:
    ongr_elasticsearch:
    managers:
            mappings:
                - AppBundle
  3. extend the existing document:
    
    namespace AppBundle\VueStorefront\Document;

use ONGR\ElasticsearchBundle\Annotation as ES;

/**

use AppBundle\VueStorefront\Document\Category; use CoreShop2VueStorefrontBundle\Bridge\DocumentMapperInterface; use Pimcore\Model\DataObject\ProductCategory;

class CategoryDocumentMapper implements DocumentMapperInterface { /**