EntityMetadataWrapperException: Unknown data property commerce_product. in EntityStructureWrapper->getPropertyInfo() (line 328 of /sites/all/modules/contrib/entity/includes/entity.wrapper.inc).
I believe this error is being caused by trying to reorder products that have been deleted. I already have a patch for this and I will post it as a comment.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | commerce_reorder-unknown_commerce_product-1416812-1.patch | 1.34 KB | nlisgo |
Comments
Comment #1
nlisgo commentedI was able to resolve the issue by amending the commerce_reorder_helper function so that it checks that a line item is a product before adding it to the cart.
Comment #2
pcambraMoving status.
I think this issue is an excellent opportunity to check the integrity of this module with non-product line items such as shipping or coupons, do we want to clone that kind of stuff? I tend to think that nope but we may want that for some use cases... however, I need to review and think about the patch you propose as it actually doesn't check if the product is currently available, which is something we may want to check and that drive us to stock.
Thanks for reporting this.
Comment #3
ikos commentedHi Pedro,
The patch here fixes a specific problem for us so I'd like to get it into the module, however you're absolutely correct that we could take it a lot further.
many thanks
Richard
Comment #4
nlisgo commentedI took the code from the commerce_cart.module file line 259. The annotation above that line reads 'If the deleted line item is a product...'
Without this check: in_array($line_item_wrapper->type->value(), commerce_product_line_item_types()) the module triggers an error because there will sometimes be no commerce_product property on the EntityStructureWrapper. This check ensures that that doesn't happen so it is vital for us.
Comment #5
pcambraSetting to needs review, I'll create a separated issue for my "integrity concerns" ;)
Comment #6
pcambraI'm committing this, thanks nlisgo!
I've added also a check for the status of the product so that we don't add disabled products either.
Let's explore the stock thing in a separate issue.
Comment #7
nlisgo commentedHappy to help