Closed (fixed)
Project:
Commerce Core
Version:
7.x-1.x-dev
Component:
Price
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
22 Oct 2012 at 02:09 UTC
Updated:
6 Jul 2016 at 18:17 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
kaidjohnson commentedAnd a proposed patch...
Comment #2
rszrama commentedI think there may be something else going on in your nodes; I never get any errors with multi-value product display nodes. Do you have a View visible on this page that includes Views aggregation? Anything else that deals with the display of price fields?
We need to dig deeper, because there's technically no reason for a display formatter to be called with an incomplete field value array. For some reason data has gone missing.
Comment #3
kaidjohnson commentedOk, that makes sense. In this particular setup, our price fields are NULL, because we're using these products to collect a variable amount (i.e. a donation). We're using Commerce Feeds to import our product data from our in-house POS, and our CSVs have no value for the price field, so no value is set... which, I think, is what ultimately throws the 'undefined index: amount' trigger. We're then using Rules to set the value of the product when it gets added to the cart based on the user's input. There are different donation levels, thus our product display aggregates a handful of various donation products, some of which have this null price.
To prevent constant patching of this issue each time we upgrade Commerce, we will update the script that generates the CSV for import to set the price to 0 if NULL. I imagine that this approach will solve the issue.
Thanks for your feedback.
Comment #4
tcmug commentedI don't know if this is related or not but curiously the same happens when I have enabled entity translation for product entities and set the price field to be translatable. In this case if I inspect the $item from the foreach loop its structure is like this:
$item = array('original' => $the_real_item_we_want);Comment #5
batigol commentedSame here.
EDIT: I cannot delete old "infected" products and create new ones. I guess the only option is to clear this directly at the database.
EDIT2: After clear the database from old products and making new ones (after upgrade commerce, entity translations, stock modules), the situation repeat it self. I'm getting this error, price is not visible, I can't add products to a cart cause of "Product not available". Am I doing something wrong here ?
Comment #6
henrix34 commentedAfter updating commerce to 1.4, set a relation to few product (in product node) and translate price field I have exactly the same error:
Comment #7
batigol commentedseems to be related with with price translation (via entity translation) only. Having a node that has more than one product associated with it doesn't seems to be related with the error above.
But price translation is crucial to display translated prices (eur [ger lang] -> usd [english] for example). Any help here ?
Comment #8
CuanMarce commentedI have the same problem of "Undefined Index..." althought I have pricing in all my products. When I applied the patch few products show up as not available, althought that is not the case. The site is international and it is important that the price be translated. Any help please!
Comment #9
adraskoy commentedI had the same issue when showing prices for more than one variation of a product in a node display. Changing from showing the calculated price to showing the fixed price got rid of the error.
Comment #10
summit commentedSo the problem is in the calculated price @adraskoy?
greetings, Martijn
Comment #11
adraskoy commentedSorry for the delayed reply. Yes, the problem occurs (for me) when using Calculated Price in a product variation when showing prices for more than one variation at the same time in a product display.
Also, it may be worth noting that I am not using translation.
Comment #12
csegyud commentedI have the same issue here. I also use calculated price to display for resellers.
I do not know if it causes any problem or just appears in the log???
Has anybody found any solutions for the problem since April? I would appreciate any help.
Thanks,
-- Csaba
Comment #13
mehrdad201 commented#7 is correct.
Thank a lot batigol.
Today, I faced this problem. I disabled translation in price field and problem is gone.
Comment #14
rszrama commentedFor others' reference, price fields should not be enabled for translation. If you need prices to appear in different currencies for different markets, you should either use Commerce Multicurrency or multiple price fields.
Comment #15
smurfxx commentedAny hint to change the label "Price" to our custom language?
I don't need to translate a number, obviously, but its label!
I tried Commerce Multicurrency and I don't see that option.
Comment #16
giorgio79 commentedI am also getting this error if the price field is left blank for a simple product...
Comment #17
tnfno commentedI thought I knew my way around Drupal, but.. where can I disable translation of the price field ????
Comment #18
summit commentedHi, for me also when the price field is left blank!.
greetings, Martijn
Comment #19
dooug commentedComment #21
rszrama commentedStill need more information before we re-open this as a bug to be fixed.
Comment #22
vensiresThe problem isn't in the commerce_price.module as stated in the error but actually in the commerce_product_pricing.module. In function commerce_product_pricing_commerce_price_field_formatter_prepare_view the code assumes a price exists and creates a display item for it even if it doesn't exist, resulting in an empty array with a "original" key and a NULL value. Attached patch should fix the issue.
Comment #23
vensiresComment #25
vensiresFailed testing... Patched again from commerce module parent folder.
Comment #26
vensiresComment #27
rossb89 commentedJust encountered this issue, @vensires is correct in regards to why this is happening.
Patch applies cleanly and appears to solve the issue, thanks!
Comment #28
summit commentedComment #29
rszrama commentedComment #30
rszrama commentedAwesome, thanks everyone. Tweaked for code style and committing.
Comment #31
rszrama commentedAnd committed.
Comment #34
theorichel commentedI know this is supposed to be solved from Commerce 1.12 and I am on 1.13, but nevertheless I have this notice:
Notice: Undefined index: amount in commerce_price_field_formatter_view() (regel 444 van /home/public/sites/www.slapeninyerseke.nl/sites/all/modules/commerce/modules/price/commerce_price.module).Comment #35
Dev_sayed commentedHi All,
The fix with me was disabling the field translation for the price field in the Product types .