I'm testing this module on the latest version of Commerce Kickstart (Drupal 7.10). When I enable Commerce Stock API then try to view an individual product display, I get the following error:
EntityMetadataWrapperException: Unknown data property commerce_product. in EntityStructureWrapper->getPropertyInfo() (line 339 of /var/aegir/platforms/drupal-7.10/sites/all/modules/entity/includes/entity.wrapper.inc).
I'm trying to troubleshoot it a bit further.

CommentFileSizeAuthor
#21 Error message30 KBGuGuss

Comments

Anonymous’s picture

I should have noted that I've followed all the instructions in the readme

Anonymous’s picture

Here's the stack trace using commerce_devel

EntityStructureWrapper->getPropertyInfo('commerce_product') entity.wrapper.inc:396
EntityStructureWrapper->get('commerce_product') entity.wrapper.inc:417
EntityStructureWrapper->__get('commerce_product') commerce_stock.module:279
commerce_stock_check_cart_product_level(282) commerce_stock.module:241
commerce_stock_cart_state_validate(Array) commerce_stock.module:70
commerce_stock_form_alter(Array, Array, 'commerce_cart_add_to_cart_form_282') module.inc:1017
drupal_alter(Array, Array, Array, 'commerce_cart_add_to_cart_form_282') form.inc:1056
drupal_prepare_form('commerce_cart_add_to_cart_form_282', Array, Array) form.inc:330
drupal_build_form('commerce_cart_add_to_cart_form_282', Array) form.inc:123
drupal_get_form('commerce_cart_add_to_cart_form_282', Object, 1, Array) commerce_cart.module:2213
commerce_cart_field_attach_view_alter(Array, Array, NULL) module.inc:1017
drupal_alter('field_attach_view', Array, Array) field.attach.inc:1185
field_attach_view('node', Object, 'full', 'en') node.module:1361
node_build_content(Object, 'full', 'en') node.module:1285
node_view(Object, 'full', NULL) node.module:2534
node_view_multiple(Array, 'full') node.module:1407
node_show(Object) node.module:2605
node_page_view(Object) 
call_user_func_array('node_page_view', Array) menu.inc:503
menu_execute_active_handler() index.php:21
Anonymous’s picture

Seems to be a problem in commerce_stock_check_cart_product_level.
The call to commerce_cart_order_load returns an object containing the current order, but something about the way that entity_metadata_wrapper is being called results in $order_wrapper being empty.

rfay’s picture

This is most often due to a failure to install the correct fields. Does your product type actually have the stock field on it successfully?

Note that Commerce Repair is made for this situation in general. But more for Commerce core... not sure what it would do here.

But I also note you're using 7.x-2.x of stock? That's pretty experimental still, as far as I understand.

guy_schneerson’s picture

douggough@drupal.org thanks for helping test V2
I got a few of questions that may help me figure out the issue:
1) Is this a fresh install and you didn't install stock V1 before the V2 version?
2) Did you only enable the API module without the Simple Stock (should be possible)?
3) Did you clear caches before testing?

Its strange that function commerce_stock_check_cart_product_level() is raising errors as its only checks what the order currently holds for the product (doesn't use the stock field), i have also added this feature to V1 (dev) so would like to make sure the function works.

is it possible for you to give me a archive/copy of your installation site and DB (if it contains no personal info), may make it easier to debug if i cant recreate the issue.

Anonymous’s picture

@rfay The stock field is there. I may try to run the repair tool. As far as the version is concerned, I like to live on the edge :)

@guy_schneerson Happy to help with anything that can improve Drupal Commerce.

  1. This is the latest Commerce Kickstart with products and product displays imported from D6 Ubercart using the Migrate module. I didn't install V1 before V2
  2. I enabled both modules, along with a few other Commerce modules before encountering the error. I then worked my way backward, disabling modules until the error went away. Disabling Simple Stock didn't solve the error, but disabling the API did.
  3. I cleared the caches before testing, and several times throughout the tests.

If I'm following the logic correctly, when the add_to_cart form loads on a product display, commerce_stock_form_alter calls commerce_stock_cart_state_validate, which calls commerce_stock_check_cart_product_level, which calls entity_metadata_wrapper and throws the error.

Anonymous’s picture

After looking at http://drupalcontrib.org/api/drupal/contributions!entity!entity.module/f... I'm unclear how the following is meant to function:

$order_wrapper = entity_metadata_wrapper('commerce_order', $order);

By calling entity_metadata_wrapper with a custom argument ('commerce_order' rather than 'entity' or 'list') and without $info, wouldn't $order get passed through to EntityValueWrapper which is only supposed to wrap a single value? Since $order is an object, perhaps that's where it's failing.

guy_schneerson’s picture

@douggough@drupal.org the entity_metadata_wrapper call should be ok the syntax expects the $type a commerce_order and $data (object /instance) the actual order and the $info array is optional.
This syntax is used all over commerce in places like the cart module:
// If the user actually has a cart order...
if ($order = commerce_cart_order_load($user->uid)) {
// Count the number of product line items on the order.
$wrapper = entity_metadata_wrapper('commerce_order', $order);

it is strange that this line of code should fail only on the stock module, are you shore you are not getting this error when the stock module is disabled?

ill try and test on a fresh install of kickstart but it is possible something may have gone wrong with D6 Ubercart using the Migrate import.

Anonymous’s picture

@guy_schneerson I'll try tomorrow on a fresh install of Commerce Kickstart with no imported data and no other contrib modules. I haven't tested in every possible context, but the particular error is only occurring when Stock is enabled and I click on a product display title in a list. When the individual product display loads, I get the error.

guy_schneerson’s picture

@douggough@drupal.org lust tested on a fresh install of he latest kickstart with no other modules except stock v2 and the kickstart products and no problems (not that it proves there are no issues).

if you are sure this only happens when stock is enabled the only thing i can suggest is debugging your site if you can provide a sensitized copy.

Anonymous’s picture

I'll do some more digging and debugging later this week. I've got another project that I have to launch before I can get back to the Commerce project. Do you want me to send you the DB and codebase? There's nothing sensitive, so I can zip it up and make it available to you on my Dropbox.

rfay’s picture

Title: EntityMetadataWrapperException » EntityMetadataWrapperException: Unknown data property commerce_product.
Assigned: Unassigned » rfay

Why don't you share it with me, and I'll take this one off of Guy's 1000 things to do. I'll PM you the email to dropbox it to.

Anonymous’s picture

Sounds good. Thanks.

Anonymous’s picture

For some strange reason I'm not allowed to view my own contact form on drupal.org. Break out your razor...it's time to start shaving some Yaks.

I'll try contacting you.

guy_schneerson’s picture

thanks Randy, let me know how you get on

Anonymous’s picture

Problem solved.

After further testing I discovered that the issue only effected the admin user. Any other user could view product displays with no issues. I had been testing the Coupon modules earlier and I created an order as admin, using a coupon. Although I deleted the coupons before uninstalling the Coupon modules, I neglected to delete the order. This resulted in an order entry in the commerce_order table that didn't appear in admin/commerce/orders. I deleted the order entry from the commerce_order table, and the error went away.

Thanks to you both for your help on this. I've learned a lot about the inner workings of Commerce along the way, so hopefully I'll be able to help some other people.

guy_schneerson’s picture

Category: bug » support
Status: Active » Fixed

glad it sorted, let us know how you got on

manos_ws’s picture

Status: Fixed » Active

I have the same error

EntityMetadataWrapperException: Unknown data property commerce_product. in EntityStructureWrapper->getPropertyInfo() (line 339 of /home/.../public_html/sites/all/modules/entity/includes/entity.wrapper.inc).

but in another situation.

When in Checkout settings I move the Shipping service pane from the Shipping page to the Checkout page.

When I disable stock api everything is ok with an empty Shipping Page.

I am using the latest commerce and stock v2 dev. my backtrace is:

EntityStructureWrapper->getPropertyInfo('commerce_product') entity.wrapper.inc:396
EntityStructureWrapper->get('commerce_product') entity.wrapper.inc:417
EntityStructureWrapper->__get('commerce_product') commerce_stock.module:279
commerce_stock_check_cart_product_level('77') commerce_stock.module:382
commerce_stock_checkout_validate(Object) commerce_stock.module:225
commerce_stock_commerce_checkout_pane_checkout_form(Array, Array, Array, Object) commerce_checkout.pages.inc:104
commerce_checkout_form(Array, Array, Object, Array) 
call_user_func_array('commerce_checkout_form', Array) form.inc:787
drupal_retrieve_form('commerce_checkout_form_checkout', Array) form.inc:331
drupal_build_form('commerce_checkout_form_checkout', Array) form.inc:123
drupal_get_form('commerce_checkout_form_checkout', Object, Array) commerce_checkout.pages.inc:58
commerce_checkout_router(Object) 
call_user_func_array('commerce_checkout_router', Array) menu.inc:517
menu_execute_active_handler() index.php:21

Thanks in advance for your help

shadowdknight’s picture

Version: 7.x-2.x-dev » 7.x-1.x-dev

Im facing the same issue on 7.x-1.x, after activating Stock, click add to cart.
Strangely it doesnt happen for anonymous.
Tried uninstall and install again with the same result.

Thanks!

guy_schneerson’s picture

i think we have a fix for this see http://drupal.org/node/1290842, a fix should be in by monday

GuGuss’s picture

StatusFileSize
new30 KB

I have the same issue (2.x-dev). Here are the steps I performed :

  • Fresh install with Commerce Kickstart
  • Enabled the Commerce Stock API and Simple Stock modules
  • Activated the stock on Product type : Product
  • Added stock on products

Then the site is not available for the admin user (see the attached image) but I still can access the overlays (as an admin) and the site works fine for anonymous user (even the check on stock quantity) !

Hope this can help.

Waiting for monday ;)

GuGuss

guy_schneerson’s picture

thanks GuGuss, i think i know what the problem is but if my suspicion is correct you must have another module installed most likely shipping.
can you pls confirm if you have other modules installed.

guy_schneerson’s picture

committed a patch for both V1 and V2 that should fix this, dev version tomorrow should include it.
patch @: http://drupal.org/node/1290842#comment-5590174

manos_ws, shadowhitman, GuGuss, pls let me know if this fixes the issue for you.

guy_schneerson’s picture

Status: Active » Reviewed & tested by the community
manos_ws’s picture

using the latest dev version fixed the issue for me!
Thanks allot

guy_schneerson’s picture

Status: Reviewed & tested by the community » Fixed
GuGuss’s picture

Fixed with the dev version !

Thanks

Status: Fixed » Closed (fixed)

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