I have create new product type with more options to customize. In Manage Fields there are plenty of Field Collections, Term Reference and one Option Set Reference. When I try to delete Product (entity in Commerce) in Admin Store I have to confirm this choice ant then I get this error:

Fatal error: Call to undefined method EntityDrupalWrapper::count() in commerce\modules\line_item\commerce_line_item.module on line 363

Comments

rszrama’s picture

Category: bug » support
Priority: Critical » Normal
Status: Needs review » Postponed (maintainer needs more info)

It sounds like you have a lot going on in this site, but honestly I'm not sure where to even begin debugging such a problem. The method in question is from the core EntityFieldQuery object, and it should definitely be there. Nothing in the line is specific to Commerce, so I can only figure you have some inconsistent state in your site making the count() method is inaccessible:

  $query = new EntityFieldQuery();
  $query->fieldCondition($key, 'line_item_id', $line_item_wrapper->line_item_id->value(), '=')->count();

It could be that fieldCondition() is throwing an error, perhaps because of an invalid $key. That's the only thing I can think of, so can you add the following code between those two lines:

  drupal_set_message('<pre>'. print_r($key, TRUE) .'</pre>', 'error');

And paste the message back in here?

fgorczynski’s picture

After few hours of scratching my head I think I found the solution (source of that problem). Product type - "Product" I had some reference trash - my bad. After deletion it works perfectly.

rszrama’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

Ok, I'll go ahead and close this one and pursue it further through #1804982: Unable to delete node with line item reference field using the line item reference widget.