Hi,
I have a Plugin where I get Prices for products. I store the price history so there are always multiple prices for every product. There are two ways and I am a little worried about performance. I would love to hear opinions and comments.
I have a .cfg file which is generated with arrays where the newest array is the newest price. The file is loaded during the update of the pricelist for every product.
So it is only:
{create_ok => 1});
my $Price = $config->{NetPrice}[0]->{NetAmount}
And I have a table with all prices which I acces like this at the moment.
$KIP->select_options ("ORDER BY Date DESC LIMIT 0,1"); #order by date DESC
my $kip_cond = GT::SQL::Condition->new();
$kip_cond->add('GTIN' => '=' => $data->{GTIN}); # item key = primary key with SupplierID
$kip_cond->add('SupplierID' => '=' => $data->{SupplierID}); # supplier key= primary key with GTIN
my $sth = $KIP->select('*', $kip_cond) || die $GT::SQL::error;
my $Price;
while (my $local_kip = $sth->fetchrow_hashref) {
$Price = $local_Kip->{NetAmount}
}The .cfg file is much quicker and I wonder how I could improve the mysql way.
Regards
n||i||k||o
I have a Plugin where I get Prices for products. I store the price history so there are always multiple prices for every product. There are two ways and I am a little worried about performance. I would love to hear opinions and comments.
I have a .cfg file which is generated with arrays where the newest array is the newest price. The file is loaded during the update of the pricelist for every product.
So it is only:
Code:
my $config = GT::Config->load($dir . "/$data->{SupplierID}/$data->{'GTIN'}/price.cfg", {create_ok => 1});
my $Price = $config->{NetPrice}[0]->{NetAmount}
And I have a table with all prices which I acces like this at the moment.
Code:
my $KIP = $DB->table('KIP'); $KIP->select_options ("ORDER BY Date DESC LIMIT 0,1"); #order by date DESC
my $kip_cond = GT::SQL::Condition->new();
$kip_cond->add('GTIN' => '=' => $data->{GTIN}); # item key = primary key with SupplierID
$kip_cond->add('SupplierID' => '=' => $data->{SupplierID}); # supplier key= primary key with GTIN
my $sth = $KIP->select('*', $kip_cond) || die $GT::SQL::error;
my $Price;
while (my $local_kip = $sth->fetchrow_hashref) {
$Price = $local_Kip->{NetAmount}
}
Regards
n||i||k||o