Revision 6b55ec18
Von Werner Hahn vor etwa 7 Jahren hinzugefügt
SL/Controller/ShopPart.pm | ||
---|---|---|
292 | 292 |
|
293 | 293 |
sub action_reorder { |
294 | 294 |
my ($self) = @_; |
295 |
|
|
296 |
require SL::DB::File; |
|
297 |
SL::DB::File->reorder_list(@{ $::form->{image_id} || [] }); |
|
295 |
require SL::DB::ShopImage; |
|
296 |
SL::DB::ShopImage->reorder_list(@{ $::form->{image_id} || [] }); |
|
298 | 297 |
|
299 | 298 |
$self->render(\'', { type => 'json' }); |
300 | 299 |
} |
SL/DB/MetaSetup/ShopImage.pm | ||
---|---|---|
13 | 13 |
id => { type => 'serial', not_null => 1 }, |
14 | 14 |
itime => { type => 'timestamp', default => 'now()' }, |
15 | 15 |
mtime => { type => 'timestamp' }, |
16 |
object_id => { type => 'text', not_null => 1 }, |
|
16 | 17 |
org_file_height => { type => 'integer' }, |
17 | 18 |
org_file_width => { type => 'integer' }, |
18 | 19 |
position => { type => 'integer' }, |
SL/DB/ShopImage.pm | ||
---|---|---|
7 | 7 |
|
8 | 8 |
use SL::DB::MetaSetup::ShopImage; |
9 | 9 |
use SL::DB::Manager::ShopImage; |
10 |
use SL::DB::Helper::ActsAsList; |
|
10 | 11 |
|
11 | 12 |
__PACKAGE__->meta->initialize; |
12 | 13 |
|
14 |
__PACKAGE__->configure_acts_as_list(group_by => [qw(object_id)]); |
|
15 |
|
|
13 | 16 |
1; |
SL/File.pm | ||
---|---|---|
253 | 253 |
org_file_height => $thumbnail->{file_image_height}, |
254 | 254 |
org_file_width => $thumbnail->{file_image_width}, |
255 | 255 |
thumbnail_content_type => $thumbnail->{thumbnail_img_content_type}, |
256 |
object_id => $file->object_id, |
|
256 | 257 |
); |
257 | 258 |
$shopimage->save; |
258 | 259 |
} |
SL/ShopConnector/Shopware.pm | ||
---|---|---|
16 | 16 |
use Sort::Naturally (); |
17 | 17 |
use SL::Helper::Flash; |
18 | 18 |
use Encode qw(encode_utf8); |
19 |
use SL::File; |
|
20 |
use File::Slurp; |
|
19 | 21 |
|
20 | 22 |
use Rose::Object::MakeMethods::Generic ( |
21 | 23 |
'scalar --get_set_init' => [ qw(connector url) ], |
... | ... | |
248 | 250 |
push ( @cat, $temp ); |
249 | 251 |
} |
250 | 252 |
|
251 |
my $images = SL::DB::Manager::File->get_all( where => [ modul => 'shop_part', trans_id => $part->{id} ]); |
|
253 |
# my $images = SL::DB::Manager::File->get_all( where => [ modul => 'shop_part', trans_id => $part->{id} ]); |
|
254 |
my $images = SL::DB::Manager::ShopImage->get_all( where => [ 'files.object_id' => $part->{id}, ], with_objects => 'file', sort_by => 'position' ); |
|
252 | 255 |
my @upload_img = (); |
253 | 256 |
foreach my $img (@{ $images }) { |
254 |
my ($path, $extension) = (split /\./, $img->{filename}); |
|
255 |
my $temp ={ ( link => 'data:' . $img->{file_content_type} . ';base64,' . MIME::Base64::encode($img->{file_content},''), |
|
256 |
description => $img->{title}, |
|
257 |
position => $img->{position}, |
|
257 |
my $file = SL::File->get(id => $img->file->id ); |
|
258 |
my $file_path = $file->get_file; |
|
259 |
my ($path, $extension) = (split /\./, $file->file_name); |
|
260 |
my $content = File::Slurp::read_file($file->get_file); |
|
261 |
my $temp ={ ( link => 'data:' . $file->mime_type . ';base64,' . MIME::Base64::encode($content), |
|
262 |
description => $img->file->title, |
|
263 |
position => $img->position, |
|
258 | 264 |
extension => $extension, |
259 | 265 |
)} ; |
260 | 266 |
push( @upload_img, $temp); |
261 | 267 |
} |
262 | 268 |
|
263 | 269 |
my ($import,$data,$data_json); |
264 |
if( $shop_part->last_update){ |
|
270 |
# if( $shop_part->last_update){
|
|
265 | 271 |
my $partnumber = $::form->escape($part->{partnumber});#shopware don't accept / in articlenumber |
266 | 272 |
$data = $self->connector->get("http://$url/api/articles/$partnumber?useNumberAsId=true"); |
267 | 273 |
$data_json = $data->content; |
268 | 274 |
$import = SL::JSON::decode_json($data_json); |
269 |
} |
|
275 |
# }
|
|
270 | 276 |
|
271 | 277 |
# get the right price |
272 | 278 |
my ( $price_src_str, $price_src_id ) = split(/\//,$shop_part->active_price_source); |
... | ... | |
339 | 345 |
], |
340 | 346 |
#attribute => { attr1 => $cvars->{CVARNAME}->{value}, } , #HowTo handle attributes |
341 | 347 |
}, |
342 |
supplier => 'Is needed by Shopware', #$part->{microfiche},
|
|
348 |
supplier => 'AR', # Is needed by shopware,
|
|
343 | 349 |
descriptionLong => $shop_part->{shop_description}, |
344 | 350 |
active => $shop_part->active, |
345 | 351 |
images => [ @upload_img ], |
sql/Pg-upgrade2/shopimages_3.sql | ||
---|---|---|
1 |
-- @tag:shopimages_3 |
|
2 |
-- @description: Neue Spalte object_id um eine group_by Klausel zu haben für act_as_list |
|
3 |
-- @charset: UTF-8 |
|
4 |
-- @depends: release_3_4_1 files shop_parts shopimages |
|
5 |
-- @ignore: 0 |
|
6 |
|
|
7 |
ALTER TABLE shop_images ADD COLUMN object_id text NOT NULL; |
Auch abrufbar als: Unified diff
Shopmodul: Bilder Sortierung und Hochladen incl. Bilder