Background
On issues https://www.drupal.org/node/1083892 and https://www.drupal.org/node/396554 the locale information was introduced, allowing users to retrieve amazon items for multiple countries
Problem
There is no locale column on the amazon_item table.
If you request the same ASIN code for a different locale, it replaces the database information.
To replicate the problem, create two ASIN fields (field_asin_us and field_asin_uk), select the autocomplete widget and specify the country codes respectively.
Now, add a new node and set the US asin to B001CEE1YE.
If you visit the node, the price will be in Dollars.
Then, add a new node and set the UK asin to B001CEE1YE.
If you visit the second, the price will be in Dollars, because it pulls from DB without locale information.
If you look into the database, there will be only one entry for the item (US version).
After few minutes the item will expire and if you refresh this page, the database will updated with the UK version. If you re-visit the first node, the price will be in British Pounds.
Also, I don’t see why only the autocomplete widget has the country code, I think the text field also needs it.
Proposed solution
- Add a new column on amazon_item field
- Add the locale parameter to all relevant functions
- Add tests
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | locale_database_storage-2920070-4.patch | 53.01 KB | marcelovani |
| #3 | locale_database_storage-2920070-3.patch | 52.67 KB | marcelovani |
Comments
Comment #2
marcelovaniComment #3
marcelovaniHere is the first patch, I think I covered a lot of it, we might have to update the other modules too
Comment #4
marcelovaniMaking the test work with multiple items
Comment #5
dakalaLana Wachowski and Lilly Wachowski are both repeated here
Code works well.
Comment #6
marcelovaniThe contents of the json file is whatever came as response form the Amazon http request
Comment #7
marcelovaniWe have been using this patch in production since November 2017 and it is working well. I am going to apply the patch against the dev branch.
Comment #8
marcelovani