It only shows products if they have at least 1 price with euro currency

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
User avatar
Wall0fDeath
Posts: 28
Joined: 30 Aug 2022, 13:56

It only shows products if they have at least 1 price with euro currency

Post by Wall0fDeath » 21 Feb 2024, 08:58

Php version: 8.2
Aimeos version: 2023.10.11
Ai-admin-jsonadm version: 2023.10.2
OS version: Debain 11 Bullseye
Laravel version: 10.43.0

Dear Aimeos Team,

I have a little problem, with the currencies. We should use the shop with HU language and HUF currency.
We loaded products and prices through XML Import, with HUF currency.

On the admin side HU lang and HUF currency are enabled, they were added and combined together like en -> eur, hu -> huf, en->huf etc. So they should be showed.

If I try to get products with jsonapi (with price, catalog, text etc...) I get everything, except the price.
I get price only if it's in euro. I had 2 price in HUF and 1 price in EUR and the jsonapi only gives me the EUR price.

Similar thing happens on the shop page. I changed lang to HU and currency to HUF on the main page, but it only shows me those products, what have at least 1 price with EUR currency.


What should I do to make it show the products with huf currency prices and to get these prices on jsonapi call or can you check this for me please?

Gagik
Posts: 38
Joined: 05 Dec 2023, 06:58

Re: It only shows products if they have at least 1 price with euro currency

Post by Gagik » 21 Feb 2024, 10:49

Hi.

Have you made any changes to your code ?

If not, you may have configured locales with currencies incorrectly in your admin panel

User avatar
Wall0fDeath
Posts: 28
Joined: 30 Aug 2022, 13:56

Re: It only shows products if they have at least 1 price with euro currency

Post by Wall0fDeath » 21 Feb 2024, 11:09

The code is the original code.

Version:
"name": "aimeos/ai-client-jsonapi",
"version": "2023.10.3",

My settings:

Image

HUF, HU are enabled too.

Product with prices:
Image

On the admin panel I have a product with 3 enabled prices. 2 with HUF currency, 1 with EURO currency.
If I try to get this with jsonapi call I get only the EURO price from the 3.

Result's relevant parts:

Code: Select all

{
	"meta": {
		"total": 1,
		"prefix": null,
		"content-baseurl": "/aimeos",
		"csrf": {
			"name": "_token",
			"value": "yufDECfVs5KIKQoeMNVGGIET5N8RX22tF4vg9PeQ"
		}
	},
	"links": {
	},
	"data": {
		"id": "20",
		"type": "product",

	},
	"attributes": {
			"product.id": "20",
			....
	},
	"relationships": {
			"price": {
				"data": [
					{
						"id": "3726",
						"type": "price",
						"attributes": {
							"product.lists.id": "45485",
							"product.lists.domain": "price",
							"product.lists.refid": "3726",
							"product.lists.datestart": null,
							"product.lists.dateend": null,
							"product.lists.config": [],
							"product.lists.position": 1,
							"product.lists.status": 1,
							"product.lists.type": "default"
						}
					}
				]
			},
	},
	"included" :[
	...
			{
			"id": "3726",
			"type": "price",
			"attributes": {
				"price.id": "3726",
				"price.type": "default",
				"price.currencyid": "EUR",
				"price.domain": "product",
				"price.quantity": 1,
				"price.value": "120.00",
				"price.costs": "0.00",
				"price.rebate": "0.00",
				"price.taxvalue": "25.5118",
				"price.taxrates": {
					"tax": "27.00"
				},
				"price.taxrate": "27.00",
				"price.taxflag": true,
				"price.status": 1,
				"price.label": ""
			}
		},
	...
	
	]

User avatar
aimeos
Administrator
Posts: 8378
Joined: 01 Jan 1970, 00:00

Re: It only shows products if they have at least 1 price with euro currency

Post by aimeos » 21 Feb 2024, 11:31

If you use the Aimeos distribution, you need to enable SHOP_MULTILOCALE=true in your .env file. Then, the JSON API URLs are like "/hu/jsonapi/product".

If you've installed the Aimeos Laravel package in your existing Laravel application, these are the relevant lines you have to add:
- https://github.com/aimeos/aimeos/blob/m ... hop.php#L4
- https://github.com/aimeos/aimeos/blob/m ... op.php#L79
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
Wall0fDeath
Posts: 28
Joined: 30 Aug 2022, 13:56

Re: It only shows products if they have at least 1 price with euro currency

Post by Wall0fDeath » 22 Feb 2024, 11:04

Thank you!

I forgot to mention, the customer wanted headless, so we are using the headless version now. Things work a little differently, but I could extend the shop.php to make this work.
I enabled multilocale and changed the jsonapi route and I can get the HUF prices now.

During this I saw that if I have multiple locale, currency pair like (EN->USD pos-1, EN->EUR, pos-2), when I call the route with EN locale and I have EUR price only (no USD), than I get back nothing. If I change the EN->EUR pair to the first one, I get back the eur price correctly.

It's just remark, but shouldn't this handle multiple locale pairs? How can I tell them apart in headless mode, if I want to provide the opportunity to have en+usd, and have en+eur (depending on the user's choice)?
Wouldn't that be better to send back all type of prices, when we are not using multilocale, than the frontend can show what it needs?

User avatar
aimeos
Administrator
Posts: 8378
Joined: 01 Jan 1970, 00:00

Re: It only shows products if they have at least 1 price with euro currency

Post by aimeos » 25 Feb 2024, 11:10

Add the "{currency}" prefix to the routes, then you can switch between language and currencies.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
Wall0fDeath
Posts: 28
Joined: 30 Aug 2022, 13:56

Re: It only shows products if they have at least 1 price with euro currency

Post by Wall0fDeath » 26 Feb 2024, 10:43

Oh. That's good. Thank you! :)

Post Reply