Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

product_version_id is not nullable in the OrderLineItem definition, but is null after deleting a product #3594

Open
Vhulcan opened this issue Mar 6, 2024 · 1 comment
Labels
Bug Good first issue Good Issue for your first contribution or experimenting with Shopware

Comments

@Vhulcan
Copy link

Vhulcan commented Mar 6, 2024

PHP Version

8.1

Shopware Version

6.5.1.1

Expected behaviour

The ProductVersionId of an OrderLineItem should be nullable, so when editing an OrderLineItem of a deleted product, the order can be saved.

Actual behaviour

When deleting a Product, both product_id and product_version_id are set to null.
But the ReferenceVersionField field of the ProductDefinition in the OrderLineItemDefinition its flagged as required.

(new ReferenceVersionField(ProductDefinition::class))->addFlags(new ApiAware(), new Required()),

The OrderLineItemEntity::getProductVersionId also states is always returns a string. But when a product is deleted it returns null;

public function getProductVersionId(): string
{
    return $this->productVersionId;
}

When editing a OrderLineItem of a deleted product, it also gives an error:

An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`order_line_item`, CONSTRAINT `order_line_item_ibfk_1` FOREIGN KEY (`product_id`, `product_version_id`) REFERENCES `product` (`id`, `version_id`) ON DELETE SET NULL ON UPDATE CAS)

How to reproduce

  1. Create a product
  2. Create an order with that product
  3. Delete the product
    The product_version_id column in the DB for te created OrderLineItem is now null.
  4. Edit the created order, by changing the quantity of the product
  5. Save the lineItem, now an error occures
@Vhulcan Vhulcan added the Bug label Mar 6, 2024
@mitelg mitelg added the Good first issue Good Issue for your first contribution or experimenting with Shopware label Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Good first issue Good Issue for your first contribution or experimenting with Shopware
Projects
None yet
2 participants