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.

Comments

nlisgo’s picture

I 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.

pcambra’s picture

Status: Active » Needs work

Moving 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.

ikos’s picture

Hi 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

nlisgo’s picture

I 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.

pcambra’s picture

Status: Needs work » Needs review

Setting to needs review, I'll create a separated issue for my "integrity concerns" ;)

pcambra’s picture

Status: Needs review » Fixed

I'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.

nlisgo’s picture

Happy to help

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.