Find the price of a product

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
earosb
Posts: 12
Joined: 13 Jul 2016, 15:30

Find the price of a product

Post by earosb » 04 Aug 2016, 21:40

Hello there,

I need to get one specific price of a product from the product id, i did this:

Code: Select all

$manager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
$item = $manager->getItem( $id, array( 'price' ) );
I want to search the price by the currencyid but i don't understand how to continue the query.

I really appreciate any help you can provide.

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

Re: Find the price of a product

Post by aimeos » 05 Aug 2016, 14:17

Your product item will now contain prices and you can retrieve them via

Code: Select all

$prices = $item->getRefitems( 'price', 'default', 'default' );
The second parameter is the price type and the third (optional) parameter is the product list type for the prices.

In the frontend, the $prices array will only contain the price items with the same currency as the used locale (site/lang/currency combination). If you've written an importer for example, $prices will contain all price items regardless of the currency by default. Then you have to iterate of the items and call $item->getCurrencyId() to check if it's the currency you need.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply