After creating a node with a blank product reference field, I get the following 2 errors when viewing that node:

Notice: Undefined index: und in commerce_product_reference_node_view() (line 58 of /Users/tom/workspace/systemseed7/profiles/systemseed/modules/contrib/commerce/modules/product_reference/commerce_product_reference.module).

Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 167 of /Users/tom/workspace/systemseed7/includes/entity.inc).

Comments

rszrama’s picture

Status: Active » Fixed

Apparently the entity_load() stuff chokes when it receives an empty value. I've updated the commerce_product_load() function to just return FALSE if passed an empty $product_id (and did the same for commerce_product_load_multiple()).

I also applied the simple fix to check for a field value before attempting to load any products to avoid the undefined index error. I wonder if there's a better API to use for determining a field's value... will look into it.

Commit: https://github.com/rszrama/drupalcommerce/commit/18f4355f6d67664b79130c0...

Status: Fixed » Closed (fixed)

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