Hello

I'm building a multilingual webshop using Commerce and Entity Translation. When I create language-neutral products, everything works fine, but when I create a product with language "Dutch", the product's Price field disappears when viewing the node in English. I also see this error message on the page:

Notice: Undefined index: amount in commerce_price_field_formatter_view() (line 397 of /home/tim/repos/drupal-cb/sites/all/modules/commerce/modules/price/commerce_price.module).

The "add to cart" button is greyed out and says "Product not available".

When viewing the product in Dutch (the same language the product was created under), I get no error message and the price field shows normally, but when I press the (now enabled) "add to cart" button, I get an exception on every page:

EntityMetadataWrapperException: Unable to get the data property data as the parent data structure is not set. in EntityStructureWrapper->getPropertyValue() (regel 442 van /home/tim/repos/drupal-cb/sites/all/modules/entity/includes/entity.wrapper.inc).

Only after manually cleaning out the cart by truncating commerce_orders (the backend's "shopping carts" overview also gives this error), the error goes away (until, of course, I add another product to my cart).

Update: Of course, "enable language fallback" is enabled in the Entity Translation settings.

Comments

rszrama’s picture

Priority: Major » Normal

Don't you also have to have some sort of field translation module on the site? Or should that not matter since prices aren't translatable?

Timusan’s picture

Hey Ryan

That's true, the field translation module is in use on the site.
But the fields translate normally, there is no problem there.
Disabling this module does not solve the problem.

I also tried a bare setup with Commerce and Entity Translation, the bug also triggers there.

For now I will solve it by putting the translatable fields inside the reference node and do the translations there.
I will begin this transition now and report back whether the "issue" (is it a Commerce issue?) also appears then.

helior’s picture

@Timusan can you still reproduce this error on a fresh install?
#1434512: Field Translation: Possible loss of data had very similar situation with field translations getting removed, however, I was not able to reproduce the error, and neither was the OP.

vasike’s picture

Status: Active » Needs review

I can't reproduce on system using last dev of Entity translation and last Drupal Commerce, 1.3

bojanz’s picture

Status: Needs review » Postponed (maintainer needs more info)

@vasike
"needs review" is only for issues with patches.

estepix’s picture

I got the exact same problem as described in #1

The way I fixed it is by making the Price field untranslatable. You need to go to:
Store > Product Type > "your-product" > Manage Fields
i.e.: admin/commerce/products/types/destination/fields
Then edit your Price field
Clic Disable translation
Confirm

If you need different currencies for different languages/countries I think the way to go is Rules, here is a link from someone tackling this use case:
http://technology.blue-bag.com/drupal-7-commerce-multi-currency-site-usi...

vasike’s picture

Status: Postponed (maintainer needs more info) » Active

indeed, i can confirm that the Price field won't work as Translatable field for Entity translation.

1. Issue for the price formatter
Notice: Undefined index: amount in commerce_price_field_formatter_view() (line 443 of drupal_path/sites/all/modules/contrib/commerce/modules/price/commerce_price.module).
it seems The entity translation changes (rebuilds) the field items structure

2. Cart issue - Product not available
it seems that commerce_product_calculate_sell_price returns NULL for this case

@estepix: What about Commerce Multicurrency module. maybe could be useful for you.

estepix’s picture

Thanks vasike, I'll give it a try

Timusan’s picture

Priority: Normal » Minor

Sorry for the late reply!

@helior : I can still reproduce the error in a fresh install with the latest version of Commerce (7.x-1.3).

I also find that the methode described in #6 is the most reasonable. Making a price field translatable is a bit silly.
Its of course more sensible to make the node that references the product with the price field translatable. Not the product itself.
So I think this has become a minor issue?

rszrama’s picture

Status: Active » Closed (fixed)

As of Commerce 1.4, we have a completely new Entity Translation integration written by that module's maintainer directly. I'm going to assume that rewrite has taken care of this bug unless someone can reproduce it with Commerce 1.4 and Entity Translation 7.x-1.0-beta1

tcmug’s picture

Status: Closed (fixed) » Active

Reproducted in Commerce 1.4 + Entity Translation 1.0-beta2 (I suppose using beta1 wouldn't fix it).

rszrama’s picture

Status: Active » Closed (duplicate)

I don't suppose this is the same issue as seen in #1843570-7: "product attribute field on Add to Cart forms" issues after upgrading to 1.4? If so, let's not reopen this one and try to get platch to weigh in there.

tcmug’s picture

That seems to be the case here; ran some sql for the price field languages and presto!

Excellent.

tcmug’s picture

Issue summary: View changes

Add update about having enabled language fallback

jimmylunad’s picture

hello

had the same problem as you, but after I emerged having surpassed other. I get the following error:

PDOException : SQLSTATE [ 42S02 ] : Base table or view not found: 1146 Table ' prueba.field_revision_commerce_display_path ' does not exist : INSERT INTO { field_revision_commerce_display_path } ( Entity_Type , entity_id , revision_id , bundle , delta , language, commerce_display_path_value , commerce_display_path_format ) VALUES ( : db_insert_placeholder_0 , : db_insert_placeholder_1 , : db_insert_placeholder_2 , : db_insert_placeholder_3 , : db_insert_placeholder_4 , : db_insert_placeholder_5 , : db_insert_placeholder_6 , : db_insert_placeholder_7 ) Array ( [ : db_insert_placeholder_0 ] = > commerce_line_item [ : db_insert_placeholder_1 ] = > 1 [ : db_insert_placeholder_2 ] = > 1 [ : db_insert_placeholder_3 ] = > product [ : db_insert_placeholder_4 ] = > 0 [ : db_insert_placeholder_5 ] = > und [ : db_insert_placeholder_6 ] = > node / 8 [ : db_insert_placeholder_7 ] = > ) in field_sql_storage_field_storage_write ( ) (line 452 of / Applications / MAMP / htdocs / changes / modules / field / modules / field_sql_storage / field_sql_storage.module ) .

someone could help me with this problem and do not know what else .

I am new to this community.

Jabastin Arul’s picture

try this

The fix is to run the following queries on the price field database tables and the related ones

update commerce_product set language='und' where language!='und';

Also run a query of the same type for the field:

update field_data_field_blabla set language='und' where language='nl';

Hope that helps.