Revision d1582152
Von Werner Hahn vor fast 8 Jahren hinzugefügt
SL/ShopConnector/Shopware.pm | ||
---|---|---|
12 | 12 |
use Data::Dumper; |
13 | 13 |
use Sort::Naturally (); |
14 | 14 |
use Encode qw(encode_utf8); |
15 |
use SL::Controller::ShopPart; |
|
15 | 16 |
|
16 | 17 |
use Rose::Object::MakeMethods::Generic ( |
17 | 18 |
'scalar --get_set_init' => [ qw(connector url) ], |
... | ... | |
197 | 198 |
my $data = $self->connector->get("http://$url/api/articles/$part->{partnumber}?useNumberAsId=true"); |
198 | 199 |
my $data_json = $data->content; |
199 | 200 |
my $import = SL::JSON::decode_json($data_json); |
200 |
# mapping to shopware |
|
201 |
|
|
202 |
# get the right price |
|
203 |
my ( $price_src_str, $price_src_id ) = split(/\//,$shop_part->active_price_source); |
|
204 |
require SL::DB::Part; |
|
205 |
my $price; |
|
206 |
if ($price_src_str eq "master_data") { |
|
207 |
my $part = SL::DB::Manager::Part->get_all( where => [id => $shop_part->part_id], with_objects => ['prices'],limit => 1)->[0]; |
|
208 |
$price = $part->$price_src_id; |
|
209 |
}else{ |
|
210 |
my $part = SL::DB::Manager::Part->get_all( where => [id => $shop_part->part_id, 'prices.'.pricegroup_id => $price_src_id], with_objects => ['prices'],limit => 1)->[0]; |
|
211 |
$price = $part->prices->[0]->price; |
|
212 |
} |
|
213 |
# mapping to shopware still missing attributes,metatags |
|
201 | 214 |
my %shop_data = ( name => $part->{description}, |
202 | 215 |
taxId => 4, # TODO Hardcoded kann auch der taxwert sein zB. tax => 19.00 |
203 | 216 |
mainDetail => { number => $part->{partnumber}, |
204 | 217 |
inStock => $part->{onhand}, |
205 | 218 |
prices => [ { from => 1, |
206 |
price => $part->{sellprice},
|
|
219 |
price => $price,
|
|
207 | 220 |
customerGroupKey => 'EK', |
208 | 221 |
}, |
209 | 222 |
], |
Auch abrufbar als: Unified diff
Shoppart: Last Upload article is written in db