Page 1 of 1

Find the price of a product

Posted: 04 Aug 2016, 21:40
by earosb
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.

Re: Find the price of a product

Posted: 05 Aug 2016, 14:17
by aimeos
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.