Closed (fixed)
Project:
Commerce Core
Version:
7.x-1.3
Component:
Line item
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
9 May 2012 at 15:31 UTC
Updated:
26 May 2012 at 08:00 UTC
Hey,
I'm receiving the error "Unknown data property commerce_product." when I make a call to commerce_product_line_item_new. Here is my code:
protected function newEntity(FeedsSource $source) {
$result = $source->preview();
$order = commerce_order_new();
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
foreach($result->items as $index){
foreach($index as $category => $value){
$product_id = 1;
$product = commerce_product_load($product_id);
$lineitem = commerce_product_line_item_new($product, $index['quantity-purchased'], $order->order_id);
commerce_line_item_save($lineitem);
$order_wrapper->commerce_line_items[] = $lineitem;
commerce_order_save($order);
}
}
return $order;
}
I am building a custom module to integrate with the Feeds module. This is inside my extension of the FeedsProccessor class. I know the error is happening on this line "$lineitem = commerce_product_line_item_new($product, $index['quantity-purchased'], $order->order_id);". It is apparent that the first parameter product is throwing the error. I have done a var_dump and know that $product is the fully loaded product object that the commerce_product_line_new requests. Any help would be awesome.
Thanks
Comments
Comment #1
rszrama commentedThe problem is actually in the function commerce_product_line_item_populate(), as commerce_product_line_item_new() never tries to access the commerce_product property. The only reason I know for this error is if your product line item type for some reason didn't have a product reference field (or I suppose if the entity info isn't being loaded early enough to let the wrapper know it exists).
To debug, further, can you check your line item type's manage fields tab to ensure the commerce_product field exists on it?
Comment #2
brandon_beeler commentedWell you're right there is no product reference field. The only fields there are Line Item Label & Quantity. I tried doing a fresh install and it done the same thing. I'm using 7.x-1.3. Maybe the problem is in that I'm not sure.
Comment #3
rszrama commentedHmm, there's no reason it shouldn't be getting added, but if this is a fresh install it probably had something to do with memory limits or other modules. No telling what might interrupt an install hook. Luckily, the http://drupal.org/project/commerce_repair module was written to repair missing fields. That should put it back, which will in turn get rid of the error.
Comment #4
klavs commentedI get the same error - also with 1.2 - and just tried upgrading to 1.3 - no change.
I checked in line item types - and both product and invest (my own added product type) has product reference fields.
What else could be causing this? What should I look for in the DB ?
My problem seems to have occured, because of a yum-upgrade that somehow failed without showing it to me. suddenIy I was missing php-gd, php-mbstring, php-pdo and php-xml modules
I'm running php-fpm (and php-5.3.13) on CentOS 6 btw. It worked fine for months - until today :(
Comment #5
klavs commentedI tried to restore the DB from 2 days go - and it still gave the same error - so for some reason Drupal recreates the error immediately :(
Comment #6
klavs commentedwith help from bojanz/irc - I tried to dsm $this->type and $this->data->type - and they say: commerce_line_item and product. according to bojanz, this points to line item type->product is missing a product ref. field - but it has such a field, and I tried modifying my product_display nodes - and they all have the product ref field - and it's filled out.
any hints as to what I can provide of debug info would be very welcome - my site is 100% down :(
Comment #7
klavs commentedtried to downgrade to php-5.3.10 (and .12) and tried switching to apache+mod_php - same problem :(
Comment #8
klavs commentedI restored my DB to last backup - and that worked. I have a dump (with extended inserts - easier to diff) of both the working and none-working, and I simply can't find the reason that makes the difference.
I'll gladly provide boths dumps, if you care to try and reproduce and figure it out.