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)
#3162 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.
#3170 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.