Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 06901b03

Von Werner Hahn vor mehr als 6 Jahren hinzugefügt

  • ID 06901b0307cbe2f7f2b4cf7dde75358e1b969b25
  • Vorgänger 1c7acbbe
  • Nachfolger d7fe5d1a

Shopmodul: Fuzzysearch für Strasse II

Unterschiede anzeigen:

SL/ShopConnector/Shopware.pm
129 129
      $shop_order->{positions} = $position-1;
130 130

  
131 131
      # Only Customers which are not found will be applied
132
      my $proposals = SL::DB::Manager::Customer->get_all_count(
133
           where => [
134
                       or => [
135
                                and  => [ # when matching names also match zipcode
136
                                          or => [ 'name' => { ilike => "%$shop_order->billing_lastname%"},
137
                                                  'name' => { ilike => "%$shop_order->billing_company%" },
138
                                                ],
139
                                          'zipcode' => { ilike => $shop_order->billing_zipcode },
140
                                        ],
141
                                and  => [ # matching street and zipcode
142
                                         'street' => { ilike => "%$shop_order->billing_street%" },
143
                                         'zipcode' => { ilike => $shop_order->billing_zipcode }
144
                                        ],
145
                                or   => [ 'email' => { ilike => $shop_order->billing_email } ],
146
                             ],
147
                    ],
148
      );
132
      my $name = $shop_order->billing_lastname ne '' ? "%" . $shop_order->billing_firstname . "%" . $shop_order->billing_lastname . "%" : '';
133
      my $lastname = $shop_order->billing_lastname ne '' ? "%" . $shop_order->billing_lastname . "%" : '';
134
      my $company = $shop_order->billing_company ne '' ? "%" . $shop_order->billing_company . "%" : '';
135
      my $street = $shop_order->billing_street ne '' ?  $shop_order->billing_street : '';
136
      # Fuzzysearch for street to find e.g. "Dorfstrasse - Dorfstr. - Dorfstraße"
137
      my $dbh = $::form->get_standard_dbh();
138
      my $fs_query = "SELECT id FROM customer WHERE ( ( (    name ILIKE ?
139
                                                          OR name ILIKE ?
140
                                                        )
141
                                                        AND zipcode ILIKE ?
142
                                                      )
143
                                                      OR ( street % ?
144
                                                           AND zipcode ILIKE ?
145
                                                         )
146
                                                      OR email ILIKE ?
147
                                                    )";
148
      my @values = ($lastname, $company, $shop_order->billing_zipcode, $street, $shop_order->billing_zipcode, $shop_order->billing_email);
149
      my @c_ids = selectall_array_query($::form, $dbh, $fs_query, @values);
150

  
151
      if(!scalar(@c_ids)){
149 152

  
150
      if(!$proposals){
151 153
        my %address = ( 'name'                  => $shop_order->billing_firstname . " " . $shop_order->billing_lastname,
152 154
                        'department_1'          => $shop_order->billing_company,
153 155
                        'department_2'          => $shop_order->billing_department,
......
168 170
                        #'payment_id'            => 7345,# TODO hardcoded
169 171
                      );
170 172
        my $customer = SL::DB::Customer->new(%address);
173
        $main::lxdebug->dump(0, 'WH:CUSTOMER ',\$customer);
174

  
171 175
        $customer->save;
172 176
        my $snumbers = "customernumber_" . $customer->customernumber;
173 177
        SL::DB::History->new(
......
177 181
                          addition    => 'SAVED',
178 182
                          what_done   => 'Shopimport',
179 183
                        )->save();
184
        $shop_order->{kivi_customer_id} = $customer->id;
185
        $shop_order->save;
180 186

  
187
      }elsif(scalar(@c_ids) == 1){
188
        my $customer = SL::DB::Manager::Customer->get_first( query => [ id => $c_ids[0], email => $shop_order->billing_email ] );
189

  
190
        if(ref $customer){
191
          $shop_order->{kivi_customer_id} = $customer->id;
192
          $shop_order->save;
193
        }
181 194
      }
182
      my %billing_address = ( 'name'     => $shop_order->billing_lastname,
183
                              'company'  => $shop_order->billing_company,
184
                              'street'   => $shop_order->billing_street,
185
                              'zipcode'  => $shop_order->billing_zipcode,
186
                              'city'     => $shop_order->billing_city,
187
                            );
188
      my $b_address = SL::Controller::ShopOrder->check_address(%billing_address);
189
      if ($b_address) {
190
        $shop_order->{kivi_customer_id} = $b_address->{id};
191
      }
192
      $shop_order->save;
193 195

  
194 196
      my $attributes->{last_order_number} = $ordnumber;
195 197
      $self->config->assign_attributes( %{ $attributes } );
......
330 332
                   );
331 333
  }elsif($todo eq "all"){
332 334
  # mapping to shopware still missing attributes,metatags
333
    %shop_data =  (  name              => $part->{description},
334
                     tax               => $taxrate,
335
                     mainDetail        => { number   => $part->{partnumber},
336
                                            inStock  => $part->{onhand},
337
                                            active   => $shop_part->active,
338
                                            prices   =>  [ { from              => 1,
339
                                                             price             => $price,
340
                                                             customerGroupKey  => 'EK',
341
                                                           },
342
                                                         ],
343
                                          },
344
                     supplier          => $cvars->{freifeld_7}->{value},
345
                     descriptionLong   => $shop_part->{shop_description},
346
                     active            => $shop_part->active,
347
                     images            => [ @upload_img ],
348
                     __options_images  => { replace => 1, },
349
                     categories        => [ @cat ],
350
                     description       => $shop_part->{shop_description},
351
                     active            => $shop_part->active,
352
                     images            => [ @upload_img ],
353
                     __options_images  => { replace => 1, },
354
                     categories        => [ @cat ],
355
                   );
356
  }else{
357
    my %shop_data =  ( mainDetail => { number   => $part->{partnumber}, });
335
    %shop_data =  (   name              => $part->{description},
336
                      mainDetail        => { number   => $part->{partnumber},
337
                                             inStock  => $part->{onhand},
338
                                             prices   =>  [ {          from   => 1,
339
                                                                       price  => $price,
340
                                                            customerGroupKey  => 'EK',
341
                                                            },
342
                                                          ],
343
                                            attribute => { attr1  => $cvars->{botanischer_name}->{value}, } ,
344
                                       },
345
                      supplier          => $part->{microfiche},
346
                      descriptionLong   => $shop_part->{shop_description},
347
                      active            => $shop_part->active,
348
                      images            => [ @upload_img ],
349
                      __options_images  => { replace => 1, },
350
                      categories        => [ @cat ],
351
                      description       => $shop_part->{shop_description},
352
                      categories        => [ @cat ],
353
                      tax               => $taxrate,
354
                    )
355
                  ;
358 356
  }
359 357

  
360 358
  my $dataString = SL::JSON::to_json(\%shop_data);
361 359
  $dataString = encode_utf8($dataString);
362

  
363 360
  my $upload_content;
364 361
  if($import->{success}){
365 362
    #update

Auch abrufbar als: Unified diff