->render();
}
-sub action_get_shop_parts {
- my ( $self ) = @_;
- $main::lxdebug->dump(0, "TST: ShopPart get_shop_parts form", $::form);
- my $parts_fetched;
- my $new_parts;
-
- my $type = $::form->{type};
- if ( $type eq "get_one" ) {
- my $shop_id = $::form->{shop_id};
- my $part_number = $::form->{part_number};
-
- if ( $shop_id && $part_number ) {
- my $shop_config = SL::DB::Manager::Shop->get_first(query => [ id => $shop_id, obsolete => 0 ]);
- my $shop = SL::Shop->new( config => $shop_config );
- unless ( SL::DB::Manager::Part->get_all_count( query => [ partnumber => $part_number ] )) {
- $new_parts = $shop->connector->get_shop_parts($part_number);
- push @{ $parts_fetched }, $new_parts ;
- } else {
- flash_later('error', t8('From shop "#1" : Number: #2 #3 ', $shop->config->description, $part_number, t8('Partnumber is already exist')));
- }
- } else {
- flash_later('error', t8('Shop or partnumber not selected.'));
- }
- } elsif ( $type eq "get_new" ) {
- my $active_shops = SL::DB::Manager::Shop->get_all(query => [ obsolete => 0 ]);
- foreach my $shop_config ( @{ $active_shops } ) {
- my $shop = SL::Shop->new( config => $shop_config );
-
- $new_parts = $shop->connector->get_shop_parts;
- push @{ $parts_fetched }, $new_parts ;
- }
- }
-
- foreach my $shop_fetched(@{ $parts_fetched }) {
- if($shop_fetched->{error}){
- flash_later('error', t8('From shop "#1" : #2 ', $shop_fetched->{shop_description}, $shop_fetched->{message},));
- }else{
- flash_later('info', t8('From shop #1 : #2 parts have been imported.', $shop_fetched->{description}, $shop_fetched->{number_of_parts},));
- }
- }
-
- $self->redirect_to(controller => "ShopPart", action => 'list_articles');
-}
-
sub action_get_categories {
my ($self) = @_;
my $shop = SL::Shop->new( config => $self->shop_part->shop );
if($self->shop_part->last_update) {
- my $shop_article = $shop->connector->get_article_info($self->shop_part->part->partnumber);
+ my $shop_article = $shop->connector->get_article($self->shop_part->part->partnumber);
$stock_onlineshop = $shop_article->{data}->{mainDetail}->{inStock};
$active_online = $shop_article->{data}->{active};
}
my $shop_part = SL::DB::Manager::ShopPart->get_all( where => [id => $part], with_objects => ['part', 'shop'])->[0];
require SL::DB::Shop;
my $shop = SL::Shop->new( config => $shop_part->shop );
- my $online_article = $shop->connector->get_article_info($shop_part->part->partnumber);
+ my $online_article = $shop->connector->get_article($shop_part->part->partnumber);
my $online_cat = $online_article->{data}->{categories};
my @cat = ();
for(keys %$online_cat){
$article->{images} = $images;
}
- $self->_setup_list_action_bar;
-
$self->render('shop_part/_list_articles', title => t8('Webshops articles'), SHOP_PARTS => $articles);
}
sub action_update {
my ($self) = @_;
-
$self->create_or_update;
}
my ($self) = @_;
my $is_new = !$self->shop_part->id;
-
my $params = delete($::form->{shop_part}) || { };
-
$self->shop_part->assign_attributes(%{ $params });
-
$self->shop_part->save;
my ( $price, $price_src_str ) = $self->get_price_n_pricesource($self->shop_part->active_price_source);
-if(!$is_new){
- flash('info', $is_new ? t8('The shop part has been created.') : t8('The shop part has been saved.'));
- $self->js->html('#shop_part_description_' . $self->shop_part->id, $self->shop_part->shop_description)
+
+ if(!$is_new){
+ flash('info', $is_new ? t8('The shop part has been created.') : t8('The shop part has been saved.'));
+ $self->js->html('#shop_part_description_' . $self->shop_part->id, $self->shop_part->shop_description)
->html('#shop_part_active_' . $self->shop_part->id, $self->shop_part->active)
->html('#price_' . $self->shop_part->id, $::form->format_amount(\%::myconfig,$price,2))
->html('#active_price_source_' . $self->shop_part->id, $price_src_str)
return($price,$price_src_str);
}
-sub _setup_list_action_bar {
- my ($self) = @_;
-
- for my $bar ($::request->layout->get('actionbar')) {
- $bar->add(
- action => [
- t8('Search'),
- submit => [ '#shop_part_filter', { action => "ShopPart/list_articles" } ],
- ],
- action => [
- t8('Get one part'),
- call => [ 'kivi.ShopPart.get_shop_parts_one_setup' ],
- tooltip => t8('Get one part by partnumber'),
- ],
- action => [
- t8('Get new parts'),
- call => [ 'kivi.ShopPart.get_shop_parts_new' ],
- tooltip => t8('Get all new parts'),
- ],
- );
- }
-}
-
sub check_auth {
$::auth->assert('shop_part_edit');
}