/** * Get the mapping data: shipping profile * * @return array */ public function getShippingProfile() { // s_core_tax $rows = Shopware()->Db()->query(' SELECT C.id, C.name name, IFNULL(PMC.plentyID, 0) plentyID FROM s_premium_dispatch C LEFT JOIN plenty_mapping_shipping_profile PMC ON PMC.shopwareID = C.id WHERE active = 1 ORDER BY C.name ')->fetchAll(); $plentyShipping = PlentymarketsImportController::getShippingProfileList(); foreach ($rows as &$row) { if ($row['plentyID']) { $row['plentyName'] = $plentyShipping[$row['plentyID']]['name']; } else { if ($this->auto) { foreach ($plentyShipping as $plentyData) { $distance = levenshtein($row['name'], $plentyData['name']); if ($distance <= 2 || strstr($plentyData['name'], $row['name'])) { $row['plentyName'] = $plentyData['name']; $row['plentyID'] = $plentyData['id']; PlentymarketsMappingController::addShippingProfile($row['id'], $plentyData['id']); if ($distance == 0) { break; } } } } else { $row['plentyName'] = ''; } } } return $rows; }