Revision 6b55ec18
Von Werner Hahn vor fast 8 Jahren hinzugefügt
SL/Controller/ShopPart.pm | ||
---|---|---|
|
||
sub action_reorder {
|
||
my ($self) = @_;
|
||
|
||
require SL::DB::File;
|
||
SL::DB::File->reorder_list(@{ $::form->{image_id} || [] });
|
||
require SL::DB::ShopImage;
|
||
SL::DB::ShopImage->reorder_list(@{ $::form->{image_id} || [] });
|
||
|
||
$self->render(\'', { type => 'json' });
|
||
}
|
SL/DB/MetaSetup/ShopImage.pm | ||
---|---|---|
id => { type => 'serial', not_null => 1 },
|
||
itime => { type => 'timestamp', default => 'now()' },
|
||
mtime => { type => 'timestamp' },
|
||
object_id => { type => 'text', not_null => 1 },
|
||
org_file_height => { type => 'integer' },
|
||
org_file_width => { type => 'integer' },
|
||
position => { type => 'integer' },
|
SL/DB/ShopImage.pm | ||
---|---|---|
|
||
use SL::DB::MetaSetup::ShopImage;
|
||
use SL::DB::Manager::ShopImage;
|
||
use SL::DB::Helper::ActsAsList;
|
||
|
||
__PACKAGE__->meta->initialize;
|
||
|
||
__PACKAGE__->configure_acts_as_list(group_by => [qw(object_id)]);
|
||
|
||
1;
|
SL/File.pm | ||
---|---|---|
org_file_height => $thumbnail->{file_image_height},
|
||
org_file_width => $thumbnail->{file_image_width},
|
||
thumbnail_content_type => $thumbnail->{thumbnail_img_content_type},
|
||
object_id => $file->object_id,
|
||
);
|
||
$shopimage->save;
|
||
}
|
SL/ShopConnector/Shopware.pm | ||
---|---|---|
use Sort::Naturally ();
|
||
use SL::Helper::Flash;
|
||
use Encode qw(encode_utf8);
|
||
use SL::File;
|
||
use File::Slurp;
|
||
|
||
use Rose::Object::MakeMethods::Generic (
|
||
'scalar --get_set_init' => [ qw(connector url) ],
|
||
... | ... | |
push ( @cat, $temp );
|
||
}
|
||
|
||
my $images = SL::DB::Manager::File->get_all( where => [ modul => 'shop_part', trans_id => $part->{id} ]);
|
||
# my $images = SL::DB::Manager::File->get_all( where => [ modul => 'shop_part', trans_id => $part->{id} ]);
|
||
my $images = SL::DB::Manager::ShopImage->get_all( where => [ 'files.object_id' => $part->{id}, ], with_objects => 'file', sort_by => 'position' );
|
||
my @upload_img = ();
|
||
foreach my $img (@{ $images }) {
|
||
my ($path, $extension) = (split /\./, $img->{filename});
|
||
my $temp ={ ( link => 'data:' . $img->{file_content_type} . ';base64,' . MIME::Base64::encode($img->{file_content},''),
|
||
description => $img->{title},
|
||
position => $img->{position},
|
||
my $file = SL::File->get(id => $img->file->id );
|
||
my $file_path = $file->get_file;
|
||
my ($path, $extension) = (split /\./, $file->file_name);
|
||
my $content = File::Slurp::read_file($file->get_file);
|
||
my $temp ={ ( link => 'data:' . $file->mime_type . ';base64,' . MIME::Base64::encode($content),
|
||
description => $img->file->title,
|
||
position => $img->position,
|
||
extension => $extension,
|
||
)} ;
|
||
push( @upload_img, $temp);
|
||
}
|
||
|
||
my ($import,$data,$data_json);
|
||
if( $shop_part->last_update){
|
||
# if( $shop_part->last_update){
|
||
my $partnumber = $::form->escape($part->{partnumber});#shopware don't accept / in articlenumber
|
||
$data = $self->connector->get("http://$url/api/articles/$partnumber?useNumberAsId=true");
|
||
$data_json = $data->content;
|
||
$import = SL::JSON::decode_json($data_json);
|
||
}
|
||
# }
|
||
|
||
# get the right price
|
||
my ( $price_src_str, $price_src_id ) = split(/\//,$shop_part->active_price_source);
|
||
... | ... | |
],
|
||
#attribute => { attr1 => $cvars->{CVARNAME}->{value}, } , #HowTo handle attributes
|
||
},
|
||
supplier => 'Is needed by Shopware', #$part->{microfiche},
|
||
supplier => 'AR', # Is needed by shopware,
|
||
descriptionLong => $shop_part->{shop_description},
|
||
active => $shop_part->active,
|
||
images => [ @upload_img ],
|
sql/Pg-upgrade2/shopimages_3.sql | ||
---|---|---|
-- @tag:shopimages_3
|
||
-- @description: Neue Spalte object_id um eine group_by Klausel zu haben für act_as_list
|
||
-- @charset: UTF-8
|
||
-- @depends: release_3_4_1 files shop_parts shopimages
|
||
-- @ignore: 0
|
||
|
||
ALTER TABLE shop_images ADD COLUMN object_id text NOT NULL;
|
Auch abrufbar als: Unified diff
Shopmodul: Bilder Sortierung und Hochladen incl. Bilder