Hello, I need some help.
I build the addon that gets the price from API and writes in the database,
database looks like
I want to fetch the last two values and compare them.
I use this repo.
In the template, I want to show all prices for each category and % higher or lower price than the previous one.
For e.x in the category with ID 3 listed prices 100 and 50.
after 50 I need to show -50% (calculated from the previous price).
Someone, to help me?
Thanks
I build the addon that gets the price from API and writes in the database,
database looks like
id | cat_id | price | currency | date |
1 | 3 | 100 | USD | 1647331547 |
2 | 3 | 50 | USD | 1647332430 |
I want to fetch the last two values and compare them.
I use this repo.
PHP:
public function findPriceFromList($catId, $applyDefaultLimit = true)
{
$finder = $this->finder('gaga\Price:Price');
$finder->where('cat_id', '=', $catId);
if ($applyDefaultLimit) {
$finder->limit(2);
}
$finder->setDefaultOrder('date', 'DESC');
return $finder;
}
In the template, I want to show all prices for each category and % higher or lower price than the previous one.
For e.x in the category with ID 3 listed prices 100 and 50.
after 50 I need to show -50% (calculated from the previous price).
Someone, to help me?
Thanks