public function resolve(CartItemInterface $item, $request) { $productId = $request->query->get('productId'); // If no product id given, or product not found, we throw exception with nice message. if (!$productId || !($product = $this->getModelRepository()->find($productId))) { throw new ItemResolvingException('Requested model was not found'); } // Assign the product to the item and define the unit price. $item->setProduct($product); $item->setSize($form->getData()); $item->setUnitPrice($product->getCostRub()); // Everything went fine, return the item. return $item; }