Revision 0be80dd0
Von Kivitendo Admin vor fast 9 Jahren hinzugefügt
SL/Shop.pm | ||
---|---|---|
|
||
use parent qw(Rose::Object);
|
||
use SL::ShopConnector::ALL;
|
||
use SL::DB::Part;
|
||
|
||
# __PACKAGE__->run_before('check_auth');
|
||
|
||
... | ... | |
'scalar --get_set_init' => [ qw(connector) ],
|
||
);
|
||
|
||
sub updatable_parts {
|
||
my ($self, $last_update) = @_;
|
||
$last_update ||= DateTime->now(); # need exact timestamp, with minutes
|
||
|
||
my $parts;
|
||
my $active_shops = SL::DB::Manager::Shop->get_all(query => [ obsolete => 0 ]);
|
||
foreach my $shop ( @{ $active_shops } ) {
|
||
# maybe run as an iterator? does that make sense with with_objects?
|
||
my $update_parts = SL::DB::Manager::ShopPart->get_all(query => [
|
||
and => [
|
||
'active' => 1,
|
||
'shop_id' => $shop->id,
|
||
# shop => '1',
|
||
or => [ 'part.mtime' => { ge => $last_update },
|
||
'part.itime' => { ge => $last_update },
|
||
'itime' => { ge => $last_update },
|
||
'mtime' => { ge => $last_update },
|
||
],
|
||
]
|
||
],
|
||
with_objects => ['shop', 'part'],
|
||
# multi_many_ok => 1,
|
||
);
|
||
push( @{ $parts }, @{ $update_parts });
|
||
};
|
||
return $parts;
|
||
|
||
};
|
||
|
||
sub init_connector {
|
||
my ($self) = @_;
|
||
# determine the connector from the connector type in the webshop config
|
||
return SL::ShopConnector::ALL->shop_connector_class_by_name($self->config->connector)->new( config => $self->config);
|
||
return SL::ShopConnector::ALL->shop_connector_class_by_name($self->config->connector)->new( config => $self->config);
|
||
|
||
};
|
||
|
||
... | ... | |
|
||
=head1 NAME
|
||
|
||
SL::WebShop - Do stuff with WebShop instances
|
||
SL::Shop - Do stuff with Shop instances
|
||
|
||
=head1 SYNOPSIS
|
||
|
||
my $config = SL::DB::Manager::WebShop->get_first();
|
||
my $config = SL::DB::Manager::Shop->get_first();
|
||
my $shop = SL::WebShop->new( config => $config );
|
||
|
||
From the config we know which Connector class to load, save in $shop->connector
|
Auch abrufbar als: Unified diff
Shop - first attempt at determining updated parts