spankrachtspankracht MemberComments: 0 Received thanks: 0 Member since: July 2020


Hopefully someone here can help us out with the following.

What we want to achieve:
Display some products from a specific productcategory below the shopping cart ({url}/checkout/cart).

Our idea:
Fetch the products via an Event Subscriber that add the data to the pagelet for use in the template; as explained here:

The problem:
While trying to fetch a category (by 'name' / or 'active == 1' for example) and it's assosiated products, we get the following 500 error:

MappingEntityClassesException - 'Mapping definition neither have entities nor collection.'

Somehow the same code (follows below) works fine when we try to access the productRepository instead of the productCategoryRespository.

Can someone please help us out?

Thank you in advance!

Code snippets follow below.


<?php declare(strict_types=1);

namespace KlikoTemplate\Subscriber;

use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsAnyFilter;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\Framework\Struct\ArrayEntity;
use Shopware\Storefront\Pagelet\Footer\FooterPageletLoadedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class UpsellSubscriber implements EventSubscriberInterface
    protected $productRepository;
	protected $productCategoryRepository;

    public function __construct(
    	EntityRepository $productRepository,
        EntityRepository $productCategoryRepository
    	$this->productRepository = $productRepository;
        $this->productCategoryRepository = $productCategoryRepository;

    public static function getSubscribedEvents(): array
        return [
			FooterPageletLoadedEvent::class => 'getProductsFromCategory'  

    public function getProductsFromCategory(FooterPageletLoadedEvent $event): void
		$criteria = new Criteria();
		//$criteria->addFilter(new EqualsFilter('name', 'Minicontainer'));
		$criteria->addFilter(new EqualsFilter('active', '1'));

		$entities = $this->productCategoryRepository->search(


		//$event->getPagelet()->addExtension('custom_upsell', $category);


<?xml version="1.0" ?>

<container xmlns="";
        <service id="KlikoTemplate\Subscriber\UpsellSubscriber" public="true">
        	<argument type="service" id="product.repository"/>
        	<argument type="service" id="product_category.repository"/>
            <tag name="kernel.event_subscriber"/>




  • akuehnisakuehnis MemberComments: 2 Received thanks: 0 Member since: September 2020

    I am running in exactely the same problem. Have you found a solution for this problem?

  • el_afiladorel_afilador MemberComments: 12 Received thanks: 1 Member since: August 2019


    Try to revert the code to productRepository and filter on a specific category id.

Sign In or Register to comment.