allowBuyInListing überschreiben

Hallo Community,

ich würde gerne die private function allowBuyInListing überschreiben. Diese liegt im ListProductService unter shopware/ListProductService.php at 5.7 · shopware/shopware · GitHub

Ich habe nun in der Doku gelesen, dass ich diese Funktion nicht mit einem Hook überschreiben kann und den Service Erweitern oder überschreiben muss. Doku: Service extensions

Ich habe nun also ein Plugin erstellt. Abgesehen vom normalen Boilerplate habe ich die services.xml

            %dupp_allow_buy_in_listing.plugin_dir%.plugin_dir%

 

Und im Ordner Bundle/StroeFrontBundle/ eine CustomListProductService.php in der ich quasi den ganzen Inhalt der ListProductService.php wiederhole:

productGateway = $productGateway;
		$this->graduatedPricesService = $graduatedPricesService;
		$this->cheapestPriceService = $cheapestPriceService;
		$this->priceCalculationService = $priceCalculationService;
		$this->mediaService = $mediaService;
		$this->marketingService = $marketingService;
		$this->voteService = $voteService;
		$this->categoryService = $categoryService;
		$this->config = $config;
	}

	/**
	 * {@inheritdoc}
	 */
	public function get($number, ProductContextInterface $context)
	{
		$products = $this->getList([$number], $context);

		return array_shift($products);
	}

	/**
	 * {@inheritdoc}
	 */
	public function getList(array $numbers, ProductContextInterface $context)
	{
		// faster replacement for array_unique()
		// see http://stackoverflow.com/questions/8321620/array-unique-vs-array-flip
		$numbers = array_keys(array_flip($numbers));

		$products = $this->productGateway->getList($numbers, $context);

		$covers = $this->mediaService->getCovers($products, $context);

		$graduatedPrices = $this->graduatedPricesService->getList($products, $context);

		$cheapestPrices = $this->cheapestPriceService->getList($products, $context);

		$voteAverages = $this->voteService->getAverages($products, $context);

		$categories = $this->categoryService->getProductsCategories($products, $context);

		$manufacturerCovers = $this->mediaService->getList($this->getManufacturerCoverIds($products), $context);

		$result = [];
		foreach ($numbers as $number) {
			if (!array_key_exists($number, $products)) {
				continue;
			}
			$product = $products[$number];

			if (isset($covers[$number])) {
				$product->setCover($covers[$number]);
			}

			if (isset($graduatedPrices[$number])) {
				$product->setPriceRules($graduatedPrices[$number]);
			}

			if (isset($cheapestPrices[$number])) {
				$product->setCheapestPriceRule($cheapestPrices[$number]);
			}

			if (isset($voteAverages[$number])) {
				$product->setVoteAverage($voteAverages[$number]);
			}

			if (isset($categories[$number])) {
				$product->setCategories($categories[$number]);
			}

			if (isset($manufacturerCovers[$product->getManufacturer()->getCoverId()])) {
				$product->getManufacturer()->setCoverMedia($manufacturerCovers[$product->getManufacturer()->getCoverId()]);
			}

			$product->addAttribute('marketing', $this->marketingService->getProductAttribute($product));

			$this->priceCalculationService->calculateProduct($product, $context);

			if (!$this->isProductValid($product, $context)) {
				continue;
			}

			$product->setListingPrice($product->getCheapestUnitPrice());
			$product->setDisplayFromPrice((count($product->getPrices()) > 1 || $product->hasDifferentPrices()));
			$product->setAllowBuyInListing($this->allowBuyInListing($product));
			if ($this->config->get('calculateCheapestPriceWithMinPurchase')) {
				$product->setListingPrice($product->getCheapestPrice());
			}
			$result[$number] = $product;
		}

		return $result;
	}

	/**
	 * Checks if the provided product is allowed to display in the store front for
	 * the provided context.
	 *
	 * @return bool
	 */
	private function isProductValid(ListProduct $product, ShopContextInterface $context)
	{
		if (in_array($context->getCurrentCustomerGroup()->getId(), $product->getBlockedCustomerGroupIds())) {
			return false;
		}

		$prices = $product->getPrices();
		if (empty($prices)) {
			return false;
		}

		if ($this->config->get('hideNoInStock') && !$product->isAvailable() && !$product->hasAvailableVariant()) {
			return false;
		}

		$ids = array_map(function (Struct\Category $category) {
			return $category->getId();
		}, $product->getCategories());

		return in_array($context->getShop()->getCategory()->getId(), $ids);
	}

	/**
	 * @return bool
	 */
	private function allowBuyInListing(ListProduct $product)
	{
		return !$product->hasConfigurator()
		       && $product->isAvailable()
		       && $product->getUnit()->getMinPurchase() <= 1
		       && !$product->displayFromPrice();
	}

	/**
	 * @param Struct\ListProduct[] $products
	 *
	 * @return array
	 */
	private function getManufacturerCoverIds($products)
	{
		$ids = array_map(function (Struct\ListProduct $product) {
			return $product->getManufacturer()->getCoverId();
		}, $products);

		return array_filter($ids);
	}
}

 

Abgesehen davon, dass das nur eine weiße Seite auswirft (abgesehen vom Header). 

Kann hier jemand helfen? Wie gehe ich weiter vor? Was mache ich falsch?

 

Danke!

 

*push*