@@ -18,12 +18,14 @@ class ProductListFacade
1818 * @param \Shopsys\FrameworkBundle\Model\Product\List\ProductListFactory $productListFactory
1919 * @param \Shopsys\FrameworkBundle\Model\Product\List\ProductListRepository $productListRepository
2020 * @param \Shopsys\FrameworkBundle\Model\Product\List\ProductListDataFactory $productListDataFactory
21+ * @param \Shopsys\FrameworkBundle\Model\Product\List\ProductListItemFactory $productListItemFactory
2122 */
2223 public function __construct (
2324 protected readonly EntityManagerInterface $ entityManager ,
2425 protected readonly ProductListFactory $ productListFactory ,
2526 protected readonly ProductListRepository $ productListRepository ,
2627 protected readonly ProductListDataFactory $ productListDataFactory ,
28+ protected readonly ProductListItemFactory $ productListItemFactory ,
2729 ) {
2830 }
2931
@@ -50,7 +52,7 @@ public function addProductToList(ProductList $productList, Product $product): Pr
5052 if ($ productList ->findProductListItemByProduct ($ product ) !== null ) {
5153 throw new ProductAlreadyInListException (sprintf ('Product with UUID %s already exists in the list. ' , $ product ->getUuid ()));
5254 }
53- $ newProductListItem = new ProductListItem ($ productList , $ product );
55+ $ newProductListItem = $ this -> productListItemFactory -> create ($ productList , $ product );
5456 $ this ->entityManager ->persist ($ newProductListItem );
5557
5658 $ productList ->addItem ($ newProductListItem );
0 commit comments