public function putAction(Request $request, $productId)
    {
        $mediaIds = $request->get('mediaIds');

        if (null === $mediaIds || !is_array($mediaIds)) {
            throw new ProductException('No media ids given.');
        }

        /** @var Product $product */
        $product = $this->getProductRepository()->find($productId);
        if (!$product) {
            throw new EntityNotFoundException($this->getProductEntityName(), $productId);
        }

        $this->getProductMediaManager()->save($product, $mediaIds);
        $this->getEntityManager()->flush();

        $view = $this->view(null, Response::HTTP_NO_CONTENT);

        return $this->handleView($view);
    }